Master process duties:
- On start, open HTTP port, or in case of graceful restart take them from the server, which is being shut down.
- Manage worker processes:
- create workers on start,
- stop and remove workers on shutdown,
- check workers availabilities,
- collect worker processes stats,
- restart hanged or dead workers.
- Collect server stats, aggregate stats from workers, and push everything into statsd service.
- Handle service queries (check option
--http-port/-H
), e.g. /server-status.
Worker processes do:
- Serve incoming HTTP requests — actually, they execute your PHP code.
- Write simple short log messages about incoming queries.
- On any warnings or errors, write corresponding messages into stderr and JSON log.
One worker can serve one request at a time. Until a request is finished, the worker doesn’t accept a new one.
Typically, you'd launch N workers on a production server, where N is a bit smaller than the number of CPU cores. Check option --workers-num/-f
.
For development, 2 workers are enough.
When the server is launched from root, it switches to the user kitten, as working from root is a bad practice. You can override it by ./server -u {username}
or even allow working from root by ./server -u root