To complete the 2nd and 3rd part of this assignment, I made a hangman game using flask and hosted it locally on a docker container.
docker build -t bolt162/hangman:latest .
The second step was to write down unit tests and run them to ensure that the game does not have edge cases where the applicaiton would crash. The test files are available in the tests/ repository and I ran the following command to run those tests:
docker run —rm bolt162/hangman: latest python -m unittest discover -s tests
docker push bolt162/hangman:latest
vagrant up vagrant ssh cd /vagrant python3 hangman.py
Request Throughput/Response Time: Used ab (ApacheBench) for load testing: ab -n 1000 -c 10 http://ip:port/
Vagrant:
Docker:
| Metric | Docker | Vagrant VM | Difference/Notes |
|---|---|---|---|
| Server Software | Werkzeug/3.1.3 | Werkzeug/2.0.3 | Different versions; may affect performance. |
| Port | 4000 | 5000 | N/A |
| Document Length | 5521 bytes | 1319 bytes | Docker serves larger responses. |
| Time Taken | 2.633 s | 20.220 s | Docker ~7.7x faster. |
| Complete Requests | 1000 | 1000 | Identical. |
| Failed Requests | 0 | 1 (Length: 1) | Vagrant had one failure. |
| Total Transferred | 5,859,000 bytes | 1,508,334 bytes | Higher in Docker due to document size. |
| HTML Transferred | 5,521,000 bytes | 1,353,297 bytes | Higher in Docker due to document size. |
| Requests per Second | 379.72 [#/sec] | 49.46 [#/sec] | Docker ~7.7x higher throughput. |
| Time per Request (mean) | 26.335 ms | 202.197 ms | Docker ~7.7x faster. |
| Time per Request (concurrent) | 2.633 ms | 20.220 ms | Docker ~7.7x faster. |
| Transfer Rate | 2172.65 KB/s | 72.85 KB/s | Docker ~29.8x higher. |
| Connect Time (min/mean/sd/max) | 0/0.6/0/18 ms | 0/0.6/0.6/13 ms | Similar; negligible differences. |
| Processing Time (min/mean/sd/max) | 15/26/6.1/73 ms | 92/201/46.4/612 ms | Docker faster, less variable. |
| Waiting Time (min/mean/sd/max) | 2/12/5.4/46 ms | 91/195/45.3/612 ms | Docker lower latency. |
| Total Time (min/mean/sd/max) | 15/26/6.1/73 ms | 92/201/46.4/612 ms | Docker ~7.7x lower mean time. |
| Latency Percentiles | Not provided | 50%: 200 ms, 75%: 226 ms, 90%: 259 ms, 95%: 279 ms | Vagrant higher tail latencies. |
The Hangman application performs significantly better in Docker, with ~7.7x higher requests per second, lower latency, and faster test completion with no failed requests. Docker's lightweight containerization likely reduces overhead compared to Vagrant's VM setup. Differences may also stem from Werkzeug versions or configurations. Docker appears more scalable, but additional tests with identical setups or varied loads are recommended.