Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support a new concurrency mode #4330

Merged
merged 1 commit into from
Aug 13, 2021
Merged

Support a new concurrency mode #4330

merged 1 commit into from
Aug 13, 2021

Conversation

doubaokun
Copy link
Contributor

  • Allow applications to control max concurrent requests on each worker (Linux) process
  • When the max_concurrency = 1, global variables and static variables are considered safe for the current request
  • Allow Laravel Octane to use coroutines at the request level to reduce the latency

@codecov
Copy link

codecov bot commented Jul 20, 2021

Codecov Report

Merging #4330 (a109d65) into master (70b2664) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4330   +/-   ##
=======================================
  Coverage   50.69%   50.69%           
=======================================
  Files          72       72           
  Lines       14516    14517    +1     
=======================================
+ Hits         7359     7360    +1     
  Misses       7157     7157           
Impacted Files Coverage Δ
src/core/base.cc 73.98% <100.00%> (+0.06%) ⬆️
src/protocol/base.cc 63.15% <0.00%> (-1.98%) ⬇️
src/os/async_thread.cc 68.85% <0.00%> (-0.44%) ⬇️
src/server/port.cc 50.27% <0.00%> (+0.27%) ⬆️
src/network/client.cc 47.09% <0.00%> (+0.44%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 70b2664...a109d65. Read the comment docs.

@matyhtf matyhtf merged commit 72c38cc into master Aug 13, 2021
@matyhtf matyhtf deleted the max_concurrency_mode branch August 13, 2021 08:10
matyhtf added a commit that referenced this pull request Aug 14, 2021
* Update version for Swoole 4.7.1

* Optimize code

* Update package.xml

* Added introducing a new concurrency mode (#4330)

Co-authored-by: matyhtf <mikan.tenny@gmail.com>
Co-authored-by: 沈唁 <52o@qq52o.cn>
Co-authored-by: Bruce Dou <doubaokun@gmail.com>
@binaryfire
Copy link

Hi all. The Laravel team is open to implementing this but they need help with the PR. See this conversation: laravel/octane#765

Do you know anyone who could help?

@deminy
Copy link
Member

deminy commented Dec 5, 2023

The configuration option max_concurrency was added for Laravel Octane. However, it's not included in the source code of Octane directly. On the other hand, Octane has coroutine disabled by default, probably to avoid any issue with third-party packages and existing projects.

In the pursuit of enabling coroutines within Octane, a practical starting point is to set max_concurrency to 1. This approach aligns with the recommendations from Mohamed Said's Asynchronous Laravel talk at Laracon Online Summer 2021. Setting max_concurrency to 1 allows the utilization of coroutines within a single HTTP request. However, it's crucial to understand that in this setup, each process is limited to handling one HTTP request at a time. As a result, in many cases a connection pool behaves more akin to a persistent connection rather than a true pool, with only one connection being utilized at any given time.

Fully leveraging Swoole's capabilities within Laravel Octane, particularly for coroutine support and handling concurrent HTTP requests, is a complex undertaking. It would likely necessitate significant refactoring. The complexity of these changes also raises concerns about their integration and acceptance within the Octane framework.

@binaryfire thanks for reaching us, and hope this helps. Please feel free to let me know if there are any questions. Thanks

@binaryfire
Copy link

Thanks for your insights @deminy. The amount of refactoring needed across the whole framework to support concurrent HTTP requests would indeed be impractical. So as you said, the most practical approach would be to set max_concurrency to 1 and just add support for using coroutines within a single request.

The question is, do you think that change would result in a noticeable performance improvement for high traffic apps?

@deminy
Copy link
Member

deminy commented Dec 6, 2023

For many apps, probably not that noticeable.

High-performance apps depend on multiple aspects, not just the underline framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants