您的位置 首页 php

Workman和swoole的区别是什么

workerman

workerman是一个高性能的PHP socket 服务器框架,workerman基于PHP多进程以及libevent事件轮询库,PHP开发者只要实现一两个接口,便可以开发出自己的网络应用,例如Rpc服务、聊天室服务器、手机游戏服务器等。

workerman的目标是让PHP开发者更容易的开发出基于 socket 的高性能的应用服务,而不用去了解PHP socket以及PHP多进程细节。 workerman本身是一个PHP多进程服务器框架,具有PHP进程管理以及socket通信的模块,所以不依赖php-fpm、 nginx 或者 apache 等这些容器便可以独立运行

其中

workerman有两种进程模型

1、基本的master worker模型

2、master gateway worker模型

master worker模型说明:

master进程为主进程,启动过程中读取conf配置,根据每个应用配置中的ip和端口创建监听socket,然后再根据配置中的进程数创建对应数量的子进程即worker进程,worker进程会自动继承master进程创建的监听socket,使得worker进程能够独立的接受并处理客户端的连接。而后master进程进入监听信号的逻辑中,监听worker进程退出信号(worker进程退出后,系统会自动向master进程发送一个SIGHCLD信号,mater进程会重新创建子进程,将缺失的子进程补上),master进程还会监听workermand脚本发来的停止信号(SIGINT)和平滑重启服务信号(SIGHUP)

worker进程为master进程派生出来的子进程,自动继承了master进程的监听socket,每个worker进程独立的接受并处理客户端的连接。

master worker模型比较适合业务简单的应用或者短连接应用

master gateway worker 模型说明:

这种模型多了一个gateway进程组,工作流程与master worker模型基本相同,区别是worker进程不再直接与客户端打交道,客户端与worker进程之间多了一个gateway进程,gateway专职处理网络 IO ,并维护客户端的长连接。

master gateway worker 模型非常适合长连接应用

swoole

Swoole是一个面向生产环境的 PHP 异步网络通信引擎,使 PHP 开发人员可以编写高性能的异步并发 TCP、UDP、Unix Socket、HTTP,WebSocket 服务。Swoole 可以广泛应用于互联网、移动通信、企业软件、云计算、网络游戏、物联网(IOT)、车联网、智能家居等领域。 使用 PHP + Swoole 作为网络通信框架,可以使企业 IT 研发团队的效率大大提升。

Swoole不是一个像Zend Framework、CakePHP、Yii、symfony、 ThinkPHP 等一样的框架,也不是一个像 WordPress 、Drupal、 Discuz 、UChome等开源产品看齐的项目。 Swoole的目标是向Java框架、Ruby On Rails、Python DjangoPylons等一流框架发起挑战。

Swoole虽然是标准的PHP扩展,实际上与普通的扩展不同。普通的扩展只是提供一个库函数。而Swoole扩展在运行后会接管PHP的控制权,进入事件循环。当IO事件发生后底层会自动回调指定的PHP函数。

swoole 底层是纯c 编写,对其他扩展几乎是零依赖,不需要php传统环境做依赖。性能更加强悍,许多国内外大公司都会在swoole的基础上进行二开来满足自己的业务需求。

文章来源:智云一二三科技

文章标题:Workman和swoole的区别是什么

文章地址:https://www.zhihuclub.com/77657.shtml

关于作者: 智云科技

热门文章

评论已关闭

29条评论

  1. The genetically engineered vaccine, first introduced for mass vaccination around 10 years ago, has been delivered to around 80 million girls, women and, in some countries, boys

  2. Although this compound showed clinical efficacy after 2 3 years of administration, this treatment invariably fails and the tumor progresses to a more aggressive stage called castration resistant prostate cancer CaPCa

  3. Lots of good nutrition things you can do to help hair grow ASAP PMID 16602149 No abstract available

  4. dexone para que sirve la ciprofloxacino hcl These savings came in areas that the ACA seeks to expand across U

  5. milnacipran, vortioxetine Automated liquid chromatography tandem mass spectrometry with electrospray ionisation based method

  6. Studies comparing the use of letrozole versus ovarian drilling revealed no differences in live birth, clinical pregnancy or OHSS rates

  7. A hysterectomy may be performed either by abdominal incision, by laparoscopy or robotically, which uses several small incisions, or vaginally

  8. s son, Max Moreno, was shot inside his Financial District high rise apartment during a drug related robbery Sept

  9. HCG mimics LH Clomid works by blocking estrogen and then triggers pituitary to produce more LH FSH right What exactly the links are between hormone levels and vulvar and vaginal pain are not well understood, but some theories exist to help our understanding

  10. All of these factors potentially skewed results thereby making it difficult to draw any significant conclusion from these studies Further, the benefit of HF medications including neurohormonal blockade, which is included in the SHFM has not been proven in the ATTR CM population

  11. Diuresis can also increase calcium excretion; the development of hypocalcemia will make signs and symptoms of hypermagnesemia worse

网站地图