All Projects → qieangel2013 → Zys

qieangel2013 / Zys

high performance service framework based on Yaf or Swoole

Projects that are alternatives of or similar to Zys

thrift2-hbase
thrift2-hbase component for Hyperf.
Stars: ✭ 14 (-98.28%)
Mutual labels:  thrift, swoole
Imi
imi 是基于 Swoole 的 PHP 协程开发框架,它支持 Http、Http2、WebSocket、TCP、UDP、MQTT 等主流协议的服务开发,特别适合互联网微服务、即时通讯聊天im、物联网等场景!。QQ群:17916227
Stars: ✭ 680 (-16.26%)
Mutual labels:  swoole
Thrifty
Thrift for Android that saves you methods
Stars: ✭ 476 (-41.38%)
Mutual labels:  thrift
Fend
Fend 是一款短小精悍,可在 FPM/Swoole 服务容器平滑切换的高性能PHP框架
Stars: ✭ 560 (-31.03%)
Mutual labels:  swoole
Cms
Feehi CMS based on yii2
Stars: ✭ 493 (-39.29%)
Mutual labels:  swoole
Hookphp
HookPHP基于C扩展搭建内置AI编程的架构系统-支持微服务部署|热插拔业务组件-集成业务模型|权限模型|UI组件库|多模板|多平台|多域名|多终端|多语言-含常驻内存|前后分离|API平台|LUA QQ群:679116380
Stars: ✭ 575 (-29.19%)
Mutual labels:  swoole
Groupco
PHP的服务化框架。适用于Api、Http Server、Rpc Server;帮助原生PHP项目转向微服务化。出色的性能与支持高并发的协程相结合
Stars: ✭ 473 (-41.75%)
Mutual labels:  swoole
Paysdk
PHP 集成支付 SDK ,集成了支付宝、微信支付的支付接口和其它相关接口的操作。支持 php-fpm 和 Swoole,所有框架通用。宇润PHP全家桶技术支持群:17916227
Stars: ✭ 723 (-10.96%)
Mutual labels:  swoole
Jboot
一个优雅的微服务框架,SpringCloud 之外的另一个选择,已经使用在用户量过亿的商业产品上,有超过1000家公司在使用Jboot做极速开发...
Stars: ✭ 655 (-19.33%)
Mutual labels:  thrift
Cpp Serializers
Benchmark comparing various data serialization libraries (thrift, protobuf etc.) for C++
Stars: ✭ 533 (-34.36%)
Mutual labels:  thrift
Srpc
RPC based on C++ Workflow
Stars: ✭ 521 (-35.84%)
Mutual labels:  thrift
Swoolefy
swoolefy是一个基于swoole实现的轻量级、高性能、协程级、开放性的API应用服务框架
Stars: ✭ 495 (-39.04%)
Mutual labels:  swoole
Bender
An easy-to-use library for creating load testing applications
Stars: ✭ 583 (-28.2%)
Mutual labels:  thrift
Fashop
php开源商城系统,基于swoole、easyswoole框架开发
Stars: ✭ 485 (-40.27%)
Mutual labels:  swoole
Ocsystem
🚀ONLYCHAIN blockchain underlying system-OCSystem
Stars: ✭ 713 (-12.19%)
Mutual labels:  swoole
Dora Rpc
DoraRPC is an RPC For the PHP MicroService by The Swoole
Stars: ✭ 475 (-41.5%)
Mutual labels:  swoole
Swoole study
一份Swoole入门教程,根据作者的个人理解编写,常见的Swoole入门知识和讲解。
Stars: ✭ 509 (-37.32%)
Mutual labels:  swoole
Swoole Jobs
🚀Dynamic multi process worker queue base on swoole, like gearman but high performance.
Stars: ✭ 574 (-29.31%)
Mutual labels:  swoole
One
一个极简高性能php框架,支持[swoole | php-fpm ]环境
Stars: ✭ 789 (-2.83%)
Mutual labels:  swoole
Scrooge
A Thrift parser/generator
Stars: ✭ 724 (-10.84%)
Mutual labels:  thrift

zys高性能服务框架

Build Status Packagist Supported PHP versions: >=5.5 License

核心特性

1.基于swoole提供分布式服务器通讯服务
2.基于thrift提供rpc远程调用服务
3.基于HTML5提供在线网络直播平台服务
4.基于swoole提供同步异步数据库连接池服务
5.基于swoole提供异步任务服务器投递任务服务
6.基于vmstat提供服务器硬件实时监控服务
7.基于yac、yaconf提供共享数据、配置服务
8.基于zqf提供高并发计数器、红包、二维码服务
9.很好的支持网页版console的shell服务
10.基于hprose提供rpc远程调用、推送等服务
11.基于zqfHB的php扩展统计php脚本执行时间的服务
12.支持命名空间、thinkphp5的ORM和部分工具类
13.全新多进程同步数据库连接池支持高并发,响应迅速

Nginx 下配置

location / {
    if (!-e $request_filename) {
       rewrite ^/(.*)$ /index.php?$1 last;
    }
}

服务启动

需要php以cli模式运行/server/server.php
    php server.php start
    php server.php stop

       php server.php restart

mysql同步多进程数据库连接池

新增mysql同步多进程数据库连接池
采用redis存储未及时处理的sql,针对多进程并发采用排他锁控制
能够自动扩容mysql客户端,根据需要自己修改,当mysql客户端处理不过来会触发扩容机制
实时捕获运行中的错误,会及时返回给用户,针对执行错或者sql错误都会记录日志并且把sql书写错误的会返回给用户
使用方法:
$data=querysql('select * from user');//注意:querysql是全局函数,只能在apache/php-fpm下使用
var_dump($data);
注意:如果服务器性能好一些,建议对https://github.com/qieangel2013/zys/blob/master/server/swoole/MySQLPollServer.php
这个文件里的poolsize_max和dilatationpool_max适当的调大一些,这样高并发下执行会很快,如果数据库配置特别差,
建议按默认的参数走

composer 安装

{
		"require": {
    		"qieangel2013/zys": "2.0.0.1"
	}
}

后台admin

后台admin访问http://www.51bixue.com:88/admin/user/index

分布式服务器通讯服务

建立多个服务器之间进行数据通信服务,服务自动连接在线服务器,支持热拔,启动服务后自动连接,无需人为干预
注意事项:
	需要在conf/application.conf里配置端口和监听、日志等
	需要有一个redis服务器,并且分布式服务器都能连接redis
	web端可以直接调用服务
	使用如下
	//注意:type为sql、file,要是需要别的功能,自己定义
    	if($_FILES){
    	//数据同步
    	$sql = array('type'=>'sql','data'=>'show tables');
    	var_dump(distributed::getInstance()->query($sql));
    	//文件同步(不用安装rsync+inotify就可以实现文件同步,并且是触发式的占用很小的资源,调用sendfile零复制)
        	$dir_pre=MYPATH.'/public/uploads/';
        	if(!is_dir($dir_pre.date('Ymd'))){
            	mkdir($dir_pre.date('Ymd'),0777,true);
    	 }
        	if(is_uploaded_file($_FILES['file']['tmp_name'])){ 
            $upname=explode('.',$_FILES['file']['name']);
            $filename=uniqid().substr(time(),-4).'.'.$upname[1];
            if(move_uploaded_file($_FILES['file']['tmp_name'],$dir_pre.date('Ymd').'/'.$filename)){  
                echo "Stored in: " . $dir_pre.date('Ymd').'/'.$filename; 
                $fileinfo = array('type'=>'file','data'=>array('path' =>'/public/uploads/'.date('Ymd').'/'.$filename,'size'=>$_FILES['file']['size'],'ext'=>$upname[1]));
                var_dump(distributed::getInstance()->queryfile($fileinfo));
            	}else{  
                	echo 'Stored failed:file save error';  
            	}  
        	}else{
            echo 'Stored failed:no post ';  
        }
   	}
   		本地访问:http:/localhost/index/distributed/
   		架构图

执行结果如下

thrift的rpc远程调用

本地访问http://localhost/index/rpc (返回0表示成功)

数据库连接池使用方法

服务文件在/server/mysql/DbServer.php
简单地封装文件在/application/library/mysql/dbclient.php
配置在conf/application.ini中
;数据库连接池配置
DbServer.async=true   //配置是同步执行还是异步执行,默认不配置代表异步执行,同步执行设置为false
DbServer.multiprocess=false //配置是否启用多进程,默认不配置代表单进程阻塞模式,多进程模式要设置为true
DbServer.pool_num=20  //配置连接池mysql的数量
DbServer.port=9501
DbServer.logfile="/server/log/DbServer.log"
DbServer.localip="192.168.2.13"
使用方法:
$dbclient=new mysql_dbclient;
    //print_r($data);
    for ($i=0; $i <100 ; $i++) { 
        $dbclient->query("INSERT INTO user(name) VALUES('$i')");
        //echo "INSERT INTO user(name) VALUES('$i')";
    }
    $data=$dbclient->query("select * from user");
    $dbclient->close();
    print_r($data);
    exit;
    本地访问:http:/localhost/index/dbtest/

数据库连接池多进程执行如下

swoole实现简单的视频直播(可以实时传音频、视频、聊天)

录制视频页面 http://localhost/index/swoolelivecamera
接受视频页面 http://localhost/index/swoolelive
采用vue+html5实现的聊天ui界面

http://www.jduxiu.com:88/live/index/index (演示地址)

liveim是一款直播平台,内置im聊天功能

由于未开源,需要授权可以获取源代码

http://www.weivq.com:88/ (演示地址)
http://www.weivq.com:88/public/uploads/LiveIm.apk (安卓演示)
http://www.weivq.com:88/public/uploads/LiveImInstall.exe (pc端演示)

vmstat服务器监控

本地访问http://localhost/vmstat/
执行如下:

yac、yaconf提供共享数据、配置使用如下

需要安装php扩展yac、yaconf
//注意:需要安装yaconf扩展,并且yaconf.directory=/tmp/yaconf 必须在php.ini里设置,不能动态加载
    echo Yaconf::get("conf.zqf");
    //注意:需要安装yac扩展,用于存储共享变量,下面的实例作为高并发计数器
    $yac = new Yac();
    $count=$yac->get('zqf');
    if(!$count){
        $yac->set('zqf', 1);
    }else{
        $yac->set('zqf', $count+0.5);
    }
    echo $count;

高并发计数器、红包、二维码使用如下

需要安装php扩展zqf
首先安装php扩展zqf.so
phpize来安装
然后在php文件调用
dl('zqf.so');或者phpini里加载([项目地址](https://github.com/qieangel2013/zqf))
$obj=new zqf();
$counter= $obj->autoadd(0,1,0);(声明只针对多线程)
echo $counter;
红包第一个参数是红包总额,第二个人参数红包数量,第三个参数默认代表拼手气红包,设置为1的话为普通红包
拼手气红包
$hongb= $obj->hongbao(10,8);或者$hongb= $obj->hongbao(10,8,0);返回数组为Array ( [0] => 1.33 [1] => 1.02 [2] => 1.28 [3] => 0.44 [4] => 1.37 [5] => 0.81 [6] => 1.81 [7] => 1.94 )
普通红包,每个人数额一样设置第三个参数
$hongb= $obj->hongbao(10,8,1);返回数组为Array ( [0] => 1.25 [1] => 1.25 [2] => 1.25 [3] => 1.25 [4] => 1.25 [5] => 1.25 [6] => 1.25 [7] => 1.25 )
var_dump($hongb);
$obj->savefile('https://www.baidu.com/s?wd=昌平香堂','./test.png',500);第一个参数是url,第二参数是保存路径,第三个参数是二维码长或者宽
$obj->savefile('https://www.baidu.com/s?wd=昌平香堂','./test.png',500,1);第一个参数是url,第二参数是保存路径,第三个参数是二维码长或者宽,第四个参数是决定是否透明,默认是不透明的

php脚本执行时间统计扩展

wget https://github.com/redis/hiredis/archive/v0.13.3.tar.gz
tar zxvf v0.13.3.tar.gz
cd hiredis-0.13.3
make
make install
如果出现libhiredis.so.0.13: cannot open shared object file: No such file or directory in Unknown on line 0
vi /etc/ld.so.conf
文件末尾添加  /usr/local/lib
然后执行ldconfig
./phpize([项目地址](https://github.com/qieangel2013/zqfHB))
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
add zqfHB.so to php.ini
extension=zqfHB.so
[zqfHB]
zqfHB.slow_maxtime=10000(单位微妙1s=1000000us,改参数是页面加载超过这个时间会统计)
zqfHB.type=1(1代表redis 2代表memcache,由于memcache性能处理有点低,暂时不开放)
zqfHB.auth=123456(如果redis没有密码,此项不必配置,如果有密码,必须配置此项)
zqfHB.host=192.168.102.163
zqfHB.port=6379
使用:
把web里的所有文件复制到网站目录下或者放在其他目录下
直接执行http://localhost/web/
效果图:

网页版console的shell使用如下

本地访问http://localhost/console/console.php

hprose的使用如下

echo hprose::getInstance()->getdata();
本地访问:http://localhost/index/hprose

交流使用

zys框架交流群:337937322

License

Apache License Version 2.0 see http://www.apache.org/licenses/LICENSE-2.0.html

如果你对我的辛勤劳动给予肯定,请给我捐赠,你的捐赠是我最大的动力

项目捐赠列表

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].