All Projects → toxmc → fast-laravel

toxmc / fast-laravel

Licence: MIT license
基于Swoole的高性能HTTP服务器,加速您Laravel应用程序。

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to fast-laravel

Laravel S
LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.
Stars: ✭ 3,479 (+10442.42%)
Mutual labels:  task, process, swoole
W7 Rangine Empty
软擎是基于 Php 7.2+ 和 Swoole 4.4+ 的高性能、简单易用的开发框架。支持同时在 Swoole Server 和 php-fpm 两种模式下运行。内置了 Http (Swoole, Fpm),Tcp,WebSocket,Process,Crontab服务。集成了大量成熟的组件,可以用于构建高性能的Web系统、API、中间件、基础服务等等。
Stars: ✭ 246 (+645.45%)
Mutual labels:  crontab, process, swoole
sw crontab
基于swoole的定时器程序,支持秒级处理,去中心化架构,可横向扩展
Stars: ✭ 24 (-27.27%)
Mutual labels:  crontab, swoole
Swoole Crontab
基于swoole的定时器程序,支持秒级处理
Stars: ✭ 900 (+2627.27%)
Mutual labels:  crontab, swoole
celery-task-tigger
A controllable timing task widgets with Celery
Stars: ✭ 57 (+72.73%)
Mutual labels:  task, crontab
Multiprocess
🚀Easy to make the common PHP/Python/js...script change daemon and multi-process execution
Stars: ✭ 151 (+357.58%)
Mutual labels:  process, swoole
TT Jobs
基于 Swoole 定时管理系统
Stars: ✭ 22 (-33.33%)
Mutual labels:  crontab, swoole
croner
Trigger functions and/or evaluate cron expressions in JavaScript. No dependencies. Most features. All environments.
Stars: ✭ 169 (+412.12%)
Mutual labels:  task, crontab
Swoft Im
基于swoft-cloud的微服务架构,最小化拆分粒度,PHP7、多进程、协程、异步任务、mysql连接池、redi连接池、rpc连接池、服务治理、服务注册与发现、Aop切面、全注解
Stars: ✭ 189 (+472.73%)
Mutual labels:  process, swoole
Ppgo job
PPGo_Job是一款可视化的、多人多权限的、一任务多机执行的定时任务管理系统,采用golang开发,安装方便,资源消耗少,支持大并发,可同时管理多台服务器上的定时任务。
Stars: ✭ 1,152 (+3390.91%)
Mutual labels:  task, crontab
Relieve
Ease the implementation of multi processing accross your microservices
Stars: ✭ 47 (+42.42%)
Mutual labels:  task, process
Swoole Task
分布式任务处理框架,基于swoole扩展,使用composer打包
Stars: ✭ 140 (+324.24%)
Mutual labels:  task, swoole
Fastd
🚀 A high performance PHP API framework.
Stars: ✭ 423 (+1181.82%)
Mutual labels:  process, swoole
Opendevops
CODO是一款为用户提供企业多混合云、一站式DevOps、自动化运维、完全开源的云管理平台、自动化运维平台
Stars: ✭ 2,990 (+8960.61%)
Mutual labels:  task, crontab
Ects
Elastic Crontab System 简单易用的分布式定时任务管理系统
Stars: ✭ 156 (+372.73%)
Mutual labels:  task, crontab
Streak-Tasks
Streak Tasks Habit Tracker
Stars: ✭ 27 (-18.18%)
Mutual labels:  tracker, task
todo.link
基于项目的任务管理系统
Stars: ✭ 90 (+172.73%)
Mutual labels:  task
time
React UI for Wobbly Time Tracker for the Teams
Stars: ✭ 24 (-27.27%)
Mutual labels:  tracker
swoole-ide-helper-phar
Swoole IDE 自动补全,PHAR 包。
Stars: ✭ 14 (-57.58%)
Mutual labels:  swoole
Flutter-Display-Tracker-
Flutter and Firebase based opensource Realtime Tracking App.
Stars: ✭ 15 (-54.55%)
Mutual labels:  tracker

中文 | English

简介

  ___                   _                             _ 
 / __)          _      | |                           | |
| |__ ____  ___| |_    | | ____  ____ ____ _   _ ____| |
|  __) _  |/___)  _)   | |/ _  |/ ___) _  | | | / _  ) |
| | ( ( | |___ | |__   | ( ( | | |  ( ( | |\ V ( (/ /| |
|_|  \_||_(___/ \___)  |_|\_||_|_|   \_||_| \_/ \____)_|                                             

🚀fast-laravel. 是基于 Swoole 实现的高性能、常驻内存的 laravel 框架 composer 扩展包, 性能较传统基于 PHP-FPM 的服务有质的提升,提供超高性能的同时,也保持着 Laravel 框架的优点。基本上无需变更业务代码的前提下即可使原有项目蜕变为常驻内存服务从而提升响应速度。 扩展提供了 热加载异步任务Crontab 秒级定时任务性能分析工具自定义进程 等非常便捷的功能,满足丰富的技术场景和业务场景,开箱即用。

扩展初衷

Laravel 是优雅的 PHP Web 开发框架。具有高效、简洁、富于表达力等优点。采用 MVC 设计, 是崇尚开发效率的全栈框架。是最受关注的 PHP 框架。然而 Laravel 最为人诟病的缺点就是:慢、笨重。 如何改变这种情况? 实际项目中也遇到接口响应速度不理想,加机器、加缓存、OPcache、升级PHP7都做了, 还是不理想,还能进一步吗?考虑到各种成本。换 go 语言还是换基于 swoole 的协程框架。 考虑到业务量,重写业务成本过高。于是 fast-laravel诞生了。

服务器要求

Fast-Laravel 基于 swoole 的所以对系统环境有一些要求,仅可运行于 LinuxMac 环境下, 但由于 Docker 虚拟化技术的发展,在 Windows 下也可以通过 Docker for Windows 来作为运行环境。 以及 Windows 下子系统的发展 WSL 也是不错的选择,推荐 Ubuntu

Docker

dockerfiles 项目内已经为您准备好了。可直接构建运行。

Windows Docker Desktop with WSL1's docker client. Docker Fedora 31, CPUs:4, Memory:4G.

docker build -t=fast-laravel dockerfiles
docker run --rm -p 9100:9100 -d fast-laravel:latest
docker exec -it `docker ps -q` /bin/bash

[root@a26c3596e1b8 www]# wrk -c32 -t8 -d 30s http://127.0.0.1:9100/api/test/info
Running 30s test @ http://127.0.0.1:9100/api/test/info
  8 threads and 32 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     6.89ms   14.42ms 318.44ms   94.69%
    Req/Sec     0.97k   233.68     2.33k    74.63%
  232532 requests in 30.09s, 52.34MB read
Requests/sec:   7727.54
Transfer/sec:      1.74MB

当您不想采用 Docker 来作为运行的环境基础时,您需要确保您的运行环境达到了以下的要求:

  • PHP >= 7.1
  • Swoole PHP 扩展 >= 4.0
  • JSON PHP 扩展
  • MongoDB PHP 扩展 (性能分析tracker使用)
  • tideways_xhprof 或 tideways PHP 扩展 (性能分析tracker使用)

安装 Fast-Laravel

Fast-Laravel 使用 Composer 来管理项目的依赖,在使用 Fast-Laravel 之前, 请确保你的运行环境已经安装好了 Composer。通过 Composer 安装。

  1. 安装 fast-laravel
    composer require toxmc/fast-laravel -vvv
    
  2. 发布配置信息
    php artisan vendor:publish --tag=fast-laravel
    
    或者
    php artisan http publish
    
  3. 生成 fast 命令所需的配置(原理复制一份 fast-laravel 启动所需的配置到 /storage/fast_laravel.json 文件中主要为了解决 configroute reload 重启不生效的问题)
    php artisan http config
    

这样 fast-laravel 扩展就安装完成了。

命令

php artisan http {action : publish|config|infos}.
action 参数意义 命令
publish 发布配置信息 php artisan http publish
config 生成fast命令所需的配置
原理:复制一份fast启动所需的配置到json文件中.
主要为了解决config和route重载不生效的问题。
php artisan http config
infos 查看服务信息 php artisan http infos
php fast http:{action : start|stop|restart|reload|infos} 
{-d|--daemon: Whether run as a daemon for start & restart}.
{-a|--access_log: It's will display access log on every request.}.
action 参数意义 命令
start 启动服务 php fast http:start
stop 停止服务 php fast http:stop
restart 重启服务 php fast http:restart
reload 重载服务 php fast http:reload
infos 查看服务信息 php fast http:infos

supervisor 管理服务

例举MAC下安装

brew install supervisor

启动

supervisord -c supervisor/supervisor.conf

管理

[xmc@mc fast-laravel (master ✗)]$ supervisorctl -c supervisor/supervisor.conf
fast-laravel-monitor             RUNNING   pid 18131, uptime 0:03:11

supervisor> help

default commands (type help <topic>):
=====================================
add    exit      open  reload  restart   start   tail   
avail  fg        pid   remove  shutdown  status  update 
clear  maintail  quit  reread  signal    stop    version

supervisor> status
fast-laravel-monitor             RUNNING   pid 29146, uptime 3:03:36

热重载

建议生产环境关闭该服务。仅限开发时使用。

  • hot_reload: 是否开启热重载
  • hot_reload_type: 热重载类型,支持 inotifytick
    • inotify 依赖 inotify PHP 扩展
    • tick 是利用 swoole 定时器,定时检测文件是否变化,进而进行 reload 操作
  • hot_reload_paths: 监控的文件变更目录。只要属于目录内的文件,发生变动,就会进行 reload
    'server'    => [
        'hot_reload'          => env('SWOOLE_HOT_RELOAD', false),
        'hot_reload_type'     => env('SWOOLE_HOT_RELOAD_TYPE', ''),// inotify or tick
        'hot_reload_paths'    => [
            base_path('app'),
            base_path('config'),
        ],
    ]

2:fswatch

brew install fswatch

[xmc@mc fast-laravel (master ✗)]$ sh fswatch.sh /Users/xmc/PhpstormProjects/iizhu/api
Starting fswatch...
File /Users/xmc/PhpstormProjects/iizhu/api/app/Service/TestService.php has been modified.
Reloading swoole_http_server...
> success
File /Users/xmc/PhpstormProjects/iizhu/api/app/Service/TestService.php has been modified.
Reloading swoole_http_server...
> success

Alternative

Alternative Framework

Others

  • Q群:190349019
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].