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

Make "async" the default server model #81

Closed
thekid opened this issue Jun 13, 2021 · 3 comments
Closed

Make "async" the default server model #81

thekid opened this issue Jun 13, 2021 · 3 comments

Comments

@thekid
Copy link
Member

thekid commented Jun 13, 2021

Currently, we have the following server models:

  • serve (the default): A single-threaded web server, blocks until one client's HTTP request handler has finished executing before serving the next request.
  • async: Same as above, but handlers can yield control back to the server to serve other clients during lengthy operations such as file up- and downloads.
  • prefork: Much like Apache, forks a given number of children to handle HTTP requests. Requires the pcntl extension.
  • develop: As mentioned above, built ontop of the PHP development wenserver. Application code is recompiled and application setup performed from scratch on every request, errors and debug output are handled by the development console.

This issue suggests making async the new default for the next major release - version 3.0.0 at the time of writing.

@thekid
Copy link
Member Author

thekid commented Jun 13, 2021

First of all, I've created a branch named two so we can easily create more 2.X releases should they be necessary.

@thekid
Copy link
Member Author

thekid commented Jun 13, 2021

The basic implementation is easy:

diff --git a/src/main/php/xp/web/Runner.class.php b/src/main/php/xp/web/Runner.class.php
index 123c6de..75e732a 100755
--- a/src/main/php/xp/web/Runner.class.php
+++ b/src/main/php/xp/web/Runner.class.php
@@ -83,7 +83,7 @@ class Runner {
     $docroot= new Path($webroot, 'static');
     $address= 'localhost:8080';
     $profile= getenv('SERVER_PROFILE') ?: 'dev';
-    $mode= 'serve';
+    $mode= 'async';
     $arguments= [];
     $config= [];
     $source= '.';

However, we should rename the serve mode to single or blocking, e.g.

@thekid
Copy link
Member Author

thekid commented Jun 14, 2021

However, we should rename the serve mode to single or blocking, e.g.

sequential

"following one after another without others coming in between"

thekid added a commit that referenced this issue Jun 14, 2021
Implements issue #81
@thekid thekid closed this as completed Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant