Docker.
docker-compose up
Starts a PHP and MySQL container on localhost (127.0.0.1) at ports 80 and 3306 respectively. Some basic test data is loaded automatically.
The entire system can be refreshed using:
docker-compose down
And then starting it back up again.
All data is returned as JSON. The endpoints are implemented in src/index.php
.
GET /
Returns a listing of all jobsGET /job
Returns the highest priority job, the next job to be processedGET /job/$id
Returns the job with the specified IDGET /process
Processes the highest priority jobGET /process/$id
Processes (or re-processes) the job with the specified IDGET /users
Lists all usersGET /user/$id
Returns the specified user and all their jobsPOST /job
Adds a new job (params:cmd, priority, user_id
)POST /register
Registers a new user (params:name
)
The attached System Diagram illustrates a basic scalable distributed system.
This design can be further scaled by:
- Separating the API servers into read/write servers
- Adding load balancers in front of the API servers
- Implementing some form of key:value memory caching for read accesses with a least recently used eviction policy