Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve HTTP server #391

Merged
merged 21 commits into from
Aug 25, 2022
Merged

Improve HTTP server #391

merged 21 commits into from
Aug 25, 2022

Conversation

vinc
Copy link
Owner

@vinc vinc commented Aug 21, 2022

  • Add root directory
  • Add support for images
  • Add support for index.html and index.txt files
  • Add read only mode
  • Add colors to logs
  • Add Request and Response structs
  • Handle concurrent requests with a connection pool
  • Improve performance by reducing wait duration

@vinc
Copy link
Owner Author

vinc commented Aug 21, 2022

Launch the server from QEMU then browse http://localhost:8080 from the host:

> dhcp
ip:  10.0.2.15/24
gw:  10.0.2.2
dns: 10.0.2.3

> httpd -r -d /var/www
HTTP Server listening on 0.0.0.0:80
10.0.2.2 - - [2022-08-21 19:21:03 +0000] "GET /" 200 876
10.0.2.2 - - [2022-08-21 19:21:04 +0000] "GET /moros.png" 200 17874
10.0.2.2 - - [2022-08-21 19:22:08 +0000] "GET /moros.bin" 404 20

@vinc
Copy link
Owner Author

vinc commented Aug 24, 2022

Adding a socket pool and limiting the time spent sleeping between polls improved the concurrency and throughput of the server, especially when using a filesystem in memory (with memory format):

> siege -c 8 -r 64 -b --no-parser http://127.0.0.1:8080
** SIEGE 4.1.2
** Preparing 8 concurrent users for battle.
The server is now under siege...
HTTP/1.0 200     0.05 secs:     876 bytes ==> GET  /
HTTP/1.0 200     0.01 secs:     876 bytes ==> GET  /
HTTP/1.0 200     0.02 secs:     876 bytes ==> GET  /
HTTP/1.0 200     0.01 secs:     876 bytes ==> GET  /
HTTP/1.0 200     0.01 secs:     876 bytes ==> GET  /
...
HTTP/1.0 200     0.02 secs:     876 bytes ==> GET  /
HTTP/1.0 200     0.01 secs:     876 bytes ==> GET  /
HTTP/1.0 200     0.01 secs:     876 bytes ==> GET  /
HTTP/1.0 200     0.02 secs:     876 bytes ==> GET  /
HTTP/1.0 200     0.00 secs:     876 bytes ==> GET  /

Transactions:		         512 hits
Availability:		      100.00 %
Elapsed time:		        5.23 secs
Data transferred:	        0.43 MB
Response time:		        0.06 secs
Transaction rate:	       97.90 trans/sec
Throughput:		        0.08 MB/sec
Concurrency:		        5.45
Successful transactions:         512
Failed transactions:	           0
Longest transaction:	        1.23
Shortest transaction:	        0.01

@vinc vinc marked this pull request as ready for review August 25, 2022 06:34
@vinc vinc merged commit f1a19e2 into trunk Aug 25, 2022
@vinc vinc deleted the feature/improve-httpd branch August 25, 2022 06:42
@vinc vinc mentioned this pull request May 5, 2023
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant