-
Notifications
You must be signed in to change notification settings - Fork 0
Program layout
Łukasz Hejnak edited this page Nov 4, 2015
·
1 revision
After consulting the requirements given by our supervisor, here are a few things to include/use:
- pthread based threads (workers)
- manual memory management (malloc etc.)
- support for simple cgi scripts (not only static files) - fork/execv
- signal handling for configuration reload/application state dump/restart (HUP/USR)
- shared memory for frequently accessed files (shared between workers)
Given the above, I suggest the following application structure:
- "main" (should use other modules for everything)
- config - loads config file on demand, keeps the config in shared RO memory for fast access
- router - watches the designated port and for launches a new worker for every connection (when all workers are busy, waits some time before returning an error - "how long" should be kept in the config)
- manager - keeps track of workers, their current status, should handle zombies (number of workers comes from config)
- worker - uses an appropriate handler to serve the request, implements basic HTTP/1.1
- handlers - currently two are planned: static file handler, cgi script handler
- static resource handler - should be used by static file handler for caching already retrieved files (up to some configured limit, then gracefully rotate the cache) - this memory should be shared between all workers/static handlers
Suggestions?