gpt4 book ai didi

Php windows server queues new requests and doesn't respond immediately until the current one finishes(PHP Windows服务器对新请求进行排队,直到当前请求完成后才立即响应)

转载 作者:bug小助手 更新时间:2023-10-24 22:58:11 24 4
gpt4 key购买 nike



I have xampp server running locally on my windows 11 machine. I start my Laravel 10 application with the command php artisan serve. In my project, I have one page that gets the uploaded file and resize it with Spatie library. I caught up php by not responding new requests until resizing image completes which means php server queues new requests until the current one finishes.

我在我的Windows11机器上本地运行了XAMPP服务器。我用命令php artisan Serve启动了我的Laravel 10应用程序。在我的项目中,我有一个页面,获得上传的文件和调整它的空间库大小。我赶上了php,直到重新调整图像大小完成才响应新请求,这意味着php服务器会将新请求排队,直到当前请求完成。


How can I achive multitasking php server with responding requests simultaneously?

如何实现同时响应请求的多任务php服务器?


I have tried

我试过了


session_start();
session_write_close();

without success.

但没有成功。


I am using Php 8.2 and laravel 10

我使用的是PHP8.2和laravel 10


更多回答

"I have xampp server running" Why are you using php artisan serve then, why not use Apache?

我让xampp服务器运行“那么你为什么使用php artisan服务器,为什么不使用apache?”

It is electron desktop app. I am using gulp-connect-php @brombeer

这是一个电子桌面应用程序。我正在使用gup-Connect-php@bromBeer

优秀答案推荐

This is because the session_start() function will create a lock on session. The session lock will be released only when the session_write_close() is called in the same request. If not called the session lock will be called by php runtime at the end of the php page execution.

这是因为SESSION_START()函数将在会话上创建一个锁。只有在同一请求中调用SESSION_WRITE_CLOSE()时,才会释放会话锁。如果不调用,会话锁将在php页面执行结束时由php运行时调用。


So if you call the page with session_start() multiple times, second request will get locked at session_start() function until the first request calls session_write_close() .

因此,如果您多次使用SESSION_START()调用页面,则第二个请求将在SESSION_START()函数中锁定,直到第一个请求调用SESSION_WRITE_CLOSE()。


Fix is to make sure to close the session(ie call session_write_close()) immediately rather than waiting till the end of the page to close it or use session start only when you need to access session data and use session_write_close() asap once the session access is over.

修复方法是确保立即关闭会话(即调用SESSION_WRITE_CLOSE()),而不是等到页面末尾才关闭它,或者只在需要访问会话数据时才使用会话启动,并在会话访问结束后尽快使用SESSION_WRITE_CLOSE()。


Read the session_write_close() function manual for more details.

有关更多详细信息,请阅读SESSION_WRITE_CLOSE()函数手册。


https://www.php.net/manual/en/function.session-write-close.php

Https://www.php.net/manual/en/function.session-write-close.php


更多回答

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com