This component takes as input requests and dispatches them to devices.
The dispatcher initializes the information about the models and containers using the services provided by the Containers Manager. Furthermore, it sends logged requests to the Requests Store.
In particular, for every request the dispatcher:
- logs the incoming request, adding the request to the log queue (the request is in the created state)
- adds the request to the application queue
- consumers select the device where forward the request using a dispatching policy
- consumers forwards the request to that device (the request is in the waiting state) using the dispatcher component
- when a response is received, consumers add the request to the log queue (in the completed state)
- the log queue in processed and sent to the request store
A thread is started at the beginning to consume the log queue that have to be sent to the Requests Store. A pool of threads is started at the beginning to consume the applications queues.
It describes how the request is forwarded to the containers. The dispatcher reads the models metadata to find out which devices are available and where the request can be forwarded.
Policies:
- Round Robin: forwards the request to the next container
- Random: forwards the request to a random container
it describes how the requests are taken from the applications queues.
Policies:
- Random: select a request from a random queue
- Round Robin: select a request from a queue with the round robin policy
- Longest Queue: select a request from the application with the longest queue
- Heuristic 1
virtualenv env
source env/bin/activate
pip install -r requirements.txt
gunicorn -w <num_of_workers> "main:create_app(delete_config=False, debug_response=False, db_echo=False)"
Arguments:
- number of workers
- containers manager host
- requests store host
- verbose
The dispatcher requires:
- Requests Store: to store the information about the requests
- Containers Manage: to get information about models and containers
See "rest-client.rest" for examples
DEFAULT PORT (gunicorn): 8000
Get the status of the component
Send a new request
- resubmit the request if timeout
- reqs cache: save the response of a request to avoid recomputing