国内C源码PHP框架选择与评价 Yaf Yar Swoole workerman?
对于韩天峰(Rango)的博客 《Yii/Yaf/Swoole 3个框架的压测性能对比》一文分析引起我作为一名 PHPer 的思考:如今PHP 的玩法越来越多,那么在大部分PHP开发中,大家是怎么看待这些框架的呢?而像BAT这些巨头类的企业,PHP开发方向他们是一个什么状态呢?
回复内容:
先放结论:- 需要极致的性能,可以接受代码执行机制和一般的 LAMP 部署方式不一致: Swoole 或 Workerman,本机 ab 压测短连接都能达到1.9W+ requests/sec;
- 需要高性能,同时需要包括完整的 MVC 支持在内的全框架特性支持:Phalcon;
- 需要高性能,专注于实现,仅需要基础的 URL 路由:Yaf。
Workerman 的核心要点和 Swoole 一致,但采用了纯 PHP 的 Web Socket 实现。和 Swoole 相比最大的好处是移除了对 C 扩展的需求,但必须采用 CLI 模式运行使其还是无法跑在虚拟主机上,但不管怎么说,起码客户端不需要依赖扩展了。
没有在生产环境中玩过以上两者,不过多评价。
Yaf 也提供了极高的性能,同时不改变原有的 PHPer 的知识架构,只是为了简洁放弃了 DB 有关的封装。但事实上这部分即重,又不是高度重复执行,确实没有必要在扩展层面实现,通过 Composer 随便装个 ORM/ActiveRecord 的包就可以了。 何况对于高性能网站的前端而言,大部分时候是不会允许去碰缓存外的东西的。
Phalcon 比起 Yaf 来说,框架特性和文档都要好很多,性能下降也并不多(仅1/10左右的差异)。
以上两者,一般来说我更推荐 Yaf,架构总是要有取舍的,认清楚 Yaf 没有像其他框架一样提供那么多舒心的特性是有原因的:别在要求高性能的场合玩那些有的没的。
所以,如果是修改较少的内部服务(比如SOA 架构中后端去除 View 了的 BLL 层),或是开放 API 系统之类,那么我推荐 Swoole / Workerman。
如果是团队不想经历较高的学习曲线(实际上面对高性能这个问题时,只有高、较高和非常高这几个选项吧?),那么就用 Yaf / Phalcon 吧。 Yaf Yar Swoole 这三个是C的扩展的框架,workerman应该是原生的PHP写的socket服务器框架。
我觉得这四个不管哪一款都是国内比较优秀的并且令人耳目一新的框架。这四款框架让我们了解到PHP不仅仅局限于做数据库的增删改查,还能实现更多重要的东西。
据我所知像BAT这类巨头企业中早已经有用原生PHP做服务器(类似workerman)类似的应用,而且有交大规模的应用和部署。 Baidu: HHVM,Yaf
阿里:主要用在Web前端
腾讯:以前是纯PHP写的Socket框架PSF,基本已经停用了,Swoole是未来的技术发展方向。 选择 C 源码类型的 PHP 框架的唯一理由是性能。 正在测试yaf框架和HHVM一起用,但不知扩展支持情况 PHP7出来了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op
