Skip to content

mbucc/tinyjhttpd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

August 10, 2021

Small server (21k jar size) that is happy with a 3M heap and stays under 120MB
resident set size when handling 50,000 requests for one toy hello world handler.
See docs/memtest_UseSerialGC_3m.txt for ApacheBench and memory usage details.

Uses Sun's original HTTP server (com.sun.net.httpserver.HttpServer) which made
it into the official Java 9 module list and Oracle appears to be maintaining.

	To run tests		make test
	To build    		make

After building, the modules are in mlib.

Note that the console logger is System.Logger implementation that logs INFO and
DEBUG log levels to stdout and ERROR to stderr.  For more info on how Java
sources use System.Logger, see docs/DIG-jdk-logging-levels.txt.

See the hello world module for an example for how to use the server.


References

  * A sample web server using the com.sun.net.httpserver package
  in the jdk.httpserver module:
  https://docs.oracle.com/en/java/javase/11/docs/api/jdk.httpserver/com/sun/net/httpserver/package-summary.html

  * Very useful page on how to use Java 9 modules:
  https://hub.packtpub.com/creating-a-simple-modular-application-in-java-11-tutorial/

  * How to use non-modular libraries (aka make an "automatic module"):
  https://www.logicbig.com/tutorials/core-java-tutorial/modules/automatic-modules.html

* Java stack vs. heap: https://www.journaldev.com/4098/java-heap-space-vs-stack-memory

About

A Java HTTP server that does not need much RAM.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages