1.9 KiB
1.9 KiB
Deployment Tips
Now that you've gone and done the hard work of making your very own HTTP server, it's time to go and share it with the world.
This page contains a list of tips that should help you get the most out of your server when it's deployed somewhere.
- Use LDC to compile the release version of your application. Compile times with LDC are a little longer than with DMD, but you get much better performance, and better compatibility with various OS/arch combinations because the project is based on LLVM.
- If using the
TaskPoolHttp1Transport, tune the number of workers according to your needs. For small services, you can usually get by just fine with only 3, and reducing the number of worker threads greatly cuts down on the overall memory footprint of your application. - Use a reverse-proxy like nginx to send traffic to Handy-Http, instead of handling it directly. This is because something like nginx is highly-optimized for maximum performance, and already handles encryption (HTTPS via SSL/TLS). This way, you can focus on the features that improve the quality of the application, instead of worrying about problems others have solved. Also, consider serving static content via reverse-proxy for best performance.
- Avoid long-duration operations while handling requests. This locks up a worker thread for the duration of the request, so it's best to respond right away (also for the user's experience) and then do additional processing asynchronously.
- Try to avoid throwing exceptions from your request handlers, where possible. Handle exceptions as soon as they crop up, and set the appropriate HTTP response code instead of relying on Handy-Http's exception handling. Exceptions are quite costly in terms of performance.