Home > Article > PHP Framework > Laravel-S can actually improve such high performance!
The following is the tutorial column of Laravel to introduce you to the high performance of Laravel-S. I hope it will be helpful to friends in need!
Recently, the company took on a secondary development project based on laravel. The customer has relatively high requirements for high concurrency. The traditional deployment of laravel project testing found that it has reached a bottleneck. Later, it was discovered that Laravel-S
can quickly integrate Swoole
to Laravel
or Lumen
, and then give them better performance, so I tried it, but it didn’t work The results were beyond my expectations, the performance was greatly improved, and the customer was very satisfied.
The following is the specific process:
1.Introduce dependencies
composer require hhxsv5/laravel-s
2.Configure .env
file
APP_NAME=test APP_ENV=local APP_KEY=base64:QXu20Ct+XlvGEnSmVzrUPXjwGARbb9R6kNo4bj5Ibps= APP_DEBUG=false APP_URL=https://xxx.com/ LOG_CHANNEL=stack DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=database DB_USERNAME=root DB_PASSWORD=root BROADCAST_DRIVER=log CACHE_DRIVER=file QUEUE_CONNECTION=sync SESSION_DRIVER=file SESSION_LIFETIME=120 REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= AWS_DEFAULT_REGION=us-east-1 AWS_BUCKET= PUSHER_APP_ID= PUSHER_APP_KEY= PUSHER_APP_SECRET= PUSHER_APP_CLUSTER=mt1 MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" JWT_SECRET=Muw2TYybFUCKxxQLcfwJB6qFMrGbUmP1uYqTCa9g9ziceE3bYz9ePM7eJOw1Reyu
3. Release configuration and binaries. There are a few things to note here. If you modify the routing or other configuration files and need to clear the cache and regenerate the configuration cache
php artisan cache:clear php artisan config:cache
Release configuration and binary files
php artisan laravels publish
4. Run
php bin/laravels start
5. Use with nginx
gzip on; gzip_min_length ; gzip_comp_level ; gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml; gzip_vary on; gzip_disable "msie6"; upstream swoole { # 通过 IP:Port 连接 server weight= max_fails= fail_timeout=30s; # 通过 UnixSocket Stream 连接,小诀窍:将socket文件放在/dev/shm目录下,可获得更好的性能 #server unix:/xxxpath/laravel-s-test/storage/laravels.sock weight= max_fails= fail_timeout=30s; #server weight= max_fails= fail_timeout=30s; #server backup; keepalive ; } server { listen ; # 别忘了绑Host哟 server_name laravels.com; root /xxxpath/laravel-s-test/public; access_log /yyypath/log/nginx/$server_name.access.log main; autoindex off; index index.html index.htm; # Nginx处理静态资源(建议开启gzip),LaravelS处理动态资源。 location / { try_files $uri @laravels; } # 当请求PHP文件时直接响应404,防止暴露public/*.php #location ~* \.php$ { # return 404; #} location @laravels { # proxy_connect_timeout 60s; # proxy_send_timeout 60s; # proxy_read_timeout 120s; 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://swoole; } }
The above is the detailed content of Laravel-S can actually improve such high performance!. For more information, please follow other related articles on the PHP Chinese website!