Foreword: I recently wanted to use swoole to try websocket. I just installed and tested the performance of laravel and swoole. I don’t know if the performance of laravel9 is optimized well. The final stress test results are similar to those of laravels~
Laradock installed swoole
Encountered problems after hands-on operation:
Because of the original PHP The version is 7.4. You need to modify the .env file and switch the version to 8.0 and above (Laravels requires php to be 8.1 when installed, so it is still set to version 8.1):
Execute again The build command succeeds. [Recommendation: laravel video tutorial]
Verification results:
Configure laravels http server
1. Install laravel project
There are many tutorials, here you can refer to: Laravel 9 Chinese Document - Installation
Based on the environment where docker is installed
curl -s "https://laravel.build/laravel9" | bashCopy
2. Install laravels
composer require hhxsv5/laravel-sCopy
3. Publish laravels configuration
php artisan laravels publishCopy
4. Configuring the site
Instructions: The project codes corresponding to the site are/var/www/laravel9/public
(1) Configure laravels http server
upstream laravels { # Connect IP:Port server workspace:5200 weight=5 max_fails=3 fail_timeout=30s; keepalive 16; } server { listen 80; server_name swoole.test; root /var/www/laravel9/public; index index.php index.html index.htm; # Nginx 处理静态资源,LaravelS 处理动态资源 location / { try_files $uri @laravels; } location @laravels { proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header Server-Protocol $server_protocol; proxy_set_header Server-Name $server_name; proxy_set_header Server-Addr $server_addr; proxy_set_header Server-Port $server_port; proxy_pass http://laravels; } error_log /var/log/nginx/swoole_test_error.log; access_log /var/log/nginx/swoole_test_access.log; }
Note: laravels project You need to add the following configuration to the .env file under the laravel9 project:
LARAVELS_LISTEN_IP=workspace LARAVELS_DAEMONIZE=trueCopy
(2) Configure the normal laravel project site
server { listen 80; listen [::]:80; # For https # listen 443 ssl; # listen [::]:443 ssl ipv6only=on; # ssl_certificate /etc/nginx/ssl/default.crt; # ssl_certificate_key /etc/nginx/ssl/default.key; server_name laravel.test; root /var/www/laravel9/public; index index.php index.html index.htm; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_pass php-upstream; fastcgi_index index.php; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #fixes timeouts fastcgi_read_timeout 600; include fastcgi_params; } location ~ /\.ht { deny all; } location /.well-known/acme-challenge/ { root /var/www/letsencrypt/; log_not_found off; } error_log /var/log/nginx/laravel_error.log; access_log /var/log/nginx/laravel_access.log; }
(3) Local host configuration
127.0.0.1 swoole.test127.0.0.1 laravel.testCopy
(4) Rebuild the container
docker-compose stop docker-compose build workspace nginx docker-compose up -d redis mysql nginx workspaceCopy
(5) Enter the workspace container and start laravels
Enter container command:
docker exec -it d4940755a928 /bin/bashCopy
AB performance test results
- Core Concern is the number of requests per second (Requests per second)
- They are all based on the Laradock environment
- Share the same project code
1. The total number of requests is 100, The number of concurrency is 10 (swoole on the left, laravel9 on the right):
2. The total number of requests is 1000, and the number of concurrency is 20 (swoole on the left, laravel9 on the right) );
The gap is not obvious, and sometimes the results of laravel9 are even better. Is such a result considered an overturn~
Original address: https://learnku.com /articles/73575
The above is the detailed content of Performance competition between laravel9 and laravels!. For more information, please follow other related articles on the PHP Chinese website!

本篇文章给大家带来了关于laravel的相关知识,其中主要介绍了关于单点登录的相关问题,单点登录是指在多个应用系统中,用户只需要登录一次就可以访问所有相互信任的应用系统,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于laravel的相关知识,其中主要介绍了关于Laravel的生命周期相关问题,Laravel 的生命周期从public\index.php开始,从public\index.php结束,希望对大家有帮助。

在laravel中,guard是一个用于用户认证的插件;guard的作用就是处理认证判断每一个请求,从数据库中读取数据和用户输入的对比,调用是否登录过或者允许通过的,并且Guard能非常灵活的构建一套自己的认证体系。

laravel中asset()方法的用法:1、用于引入静态文件,语法为“src="{{asset(‘需要引入的文件路径’)}}"”;2、用于给当前请求的scheme前端资源生成一个url,语法为“$url = asset('前端资源')”。

本篇文章给大家带来了关于laravel的相关知识,其中主要介绍了关于使用中间件记录用户请求日志的相关问题,包括了创建中间件、注册中间件、记录用户访问等等内容,下面一起来看一下,希望对大家有帮助。

本篇文章给大家带来了关于laravel的相关知识,其中主要介绍了关于中间件的相关问题,包括了什么是中间件、自定义中间件等等,中间件为过滤进入应用的 HTTP 请求提供了一套便利的机制,下面一起来看一下,希望对大家有帮助。

在laravel中,fill方法是一个给Eloquent实例赋值属性的方法,该方法可以理解为用于过滤前端传输过来的与模型中对应的多余字段;当调用该方法时,会先去检测当前Model的状态,根据fillable数组的设置,Model会处于不同的状态。

laravel路由文件在“routes”目录里。Laravel中所有的路由文件定义在routes目录下,它里面的内容会自动被框架加载;该目录下默认有四个路由文件用于给不同的入口使用:web.php、api.php、console.php等。


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

Atom editor mac version download
The most popular open source editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
