Download the PHP package upscale/swoole-dispatch without Composer
On this page you can find all versions of the php package upscale/swoole-dispatch. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download upscale/swoole-dispatch
More information about upscale/swoole-dispatch
Files in upscale/swoole-dispatch
Package swoole-dispatch
Short Description Request dispatch strategies for Swoole web-server
License Apache-2.0
Homepage https://github.com/upscalesoftware/swoole-dispatch
Informations about the package swoole-dispatch
Request Dispatch for Swoole
This is a collection of request dispatch strategies for Swoole web-server that compliment the built-in dispatch modes. Sticky session dispatch strategy also known as the session affinity is the cornerstone of this library. Other strategies are provided as a fallback for guest requests without the session context. They mimic the native dispatch modes that are by design mutually exclusive to the custom dispatch function.
Strategies:
- Fixed Client
- Dispatch requests to workers by Client ID
- Round Robin
- Dispatch requests to workers in circular order
- Sticky Session
- Dispatch requests to workers by Session ID
- Session ID in query string
- Session ID in cookies
- URL Path
- Dispatch requests to workers by URL path
- Query string excluded or included
- Custom URL path pattern
- HTTP method filters
Installation
The library is to be installed via Composer as a dependency:
Dispatch Strategies
Fixed Client
Dispatch requests to workers according to client connection ID equivalent to the built-in fixed dispatch mode.
Register the dispatcher:
Send some test requests:
-
Different connections are distributed between all workers:
- Every connection is dispatched to a dedicated worker:
Round Robin
Dispatch requests to workers in circular order equivalent to the built-in polling dispatch mode.
Register the dispatcher:
Send some test requests:
- Requests of all connections are distributed between all workers:
Sticky Session
Dispatch requests to workers according to session ID for sticky session also known as session affinity. All requests belonging to a session will be dispatched to a dedicated worker process. Session ID is recognized in a query string and cookie headers in that order of priority.
This strategy is complimentary to the session locking and can compensate for the lack of thereof. It prevents race conditions in workers competing for an exclusive lock of the same session ID. Workers only pick up requests of their respective sessions as well as guest requests without the session context.
Dispatch of guest requests will be delegated to a specified fallback strategy of choice.
Register the sticky session dispatcher with fallback to the Round-Robin for guests:
Send some test requests with and without the session context:
-
Guest requests are delegated to the fallback strategy Round-Robin:
- Session requests are dispatched to a dedicated worker:
URL Path
Dispatch requests to workers according to a URL path of a HTTP request.
Configure whether to use a query string in addition to the path or not (the default).
Custom URL path filter can be provided via the PCRE regular expression syntax.
The dispatch can also be limited to a given HTTP methods (HEAD
and GET
by default).
Register the URL path dispatcher with fallback to the Round-Robin:
Send some test requests:
- Requests are dispatched to a dedicated worker by URL path:
Contributing
Pull Requests with fixes and improvements are welcome!
License
Copyright © Upscale Software. All rights reserved.
Licensed under the Apache License, Version 2.0.
All versions of swoole-dispatch with dependencies
ext-swoole Version ^4.0