Lwan is a lightweight asynchronous multi-threaded event-based web server.
Lwan was until recently just a personal research effort that focused mostly on building a solid infrastructure for a lightweight and speedy web server.
With its low disk and memory footprints, it’s suitable to be used from embedded devices to robust servers. Both static and dynamic content can be served, as it can also be used as a library. Dynamic content can be generated by code written in either C or Lua.
Its simple architecture and tiny source code guarantees the entire code base can be easily grokked.
This is free and open source software.
Features include:
- Low memory footprint (~500KiB for 10k idle connections).
- Small disk footprint: x86-64 executable has 198KiB (~86KiB if packed with UPX).
- Minimal memory allocations & copies.
- Minimal system calls.
- Hand-written HTTP request parser.
- Static file serving uses the most efficient way according to file size/;
- No copies between kernel and userland for files larger than 16KiB.
- Smaller files are sent using scatter-gather I/O.
- Header overhead is considered before considering deflate, zstd, or Brotli compression.
- Precompressed files are sent if the client asks for gzip compression.
- Mostly wait-free multi-threaded design:
- One thread accepts connections, one I/O thread per logical CPU handles them.
- One coroutines per connection makes asynchronous I/O a breeze in C.
- Supports Linux, OpenBSD, FreeBSD and macOS.
- Purpose-built I/O loop with async/await and timer support.
- Efficient, Guava-inspired loading cache. Used for:
- Directory listing.
- File information (size, last modified date, MIME type, etc).
- Compressed file contents.
- Compiled Lua scripts.
- Request rewriting support based on Lua pattern matching syntax:
- Lua scripts can be executed to control the rewriting behavior as well.
- Diminutive codebase with roughly 20000 lines of GNU11 code.
- Efficient Mustache templating engine:
- Used internally for directory listing & error messages (can be loaded from a file).
- Available for user-built handlers.
- Easy to use API to create web applications or extend the web server:
- Example: Freegeoip reimplementation, which performs better than the Go version and is roughly the same amount of lines of code. The live version has been up for years, and serves millions of requests per day, with a RSS of roughtly 5MiB.
- Handlers can be written in C and Lua.
- Supports rebimboca da parafuseta.
- No-nonsense configuration file syntax.
- Supports a subset of HTTP/1.0 and HTTP/1.1:
- Support for keep-alive connections.
- Support for pipelined requests.
- WebSockets.
- FastCGI.
- PROXY protocol support.
- Useful for TLS terminators such as Hitch.
- TLSv1.2 support with AES encryption offload (kTLS on Linux), with TLSv1.3 in the works.
systemd socket activation. - Named socket support for both TLS and non-TLS listeners.
- IPv6 ready.
- A continuous integration systems helps keep the house in order:
- Buildbots checks every commit (instance).
- Code is statically analyzed by Clang Static Analyzer.
- Debug & Release builds are tested and built.
- Workers build Lwan on various different platforms:
- Arch Linux (x86-64), always up-to-date.
- Debian GNU/Linux (aarch64).
- FreeBSD 10 and 11
- OpenBSD 6.6 (x86-64).
- macOS High Sierra (x86-64).
- Test suite written in Python tests the server as a black box.
- Test suite is executed with both Undefined Behavior and Address sanitizers on Linux and OpenBSD.
- Request parser continuously fuzzed with oss-fuzz.
Website: lwan.ws
Support: GitHub Code Repository
Developer: L. Pereira
License: GNU General Public License v2.0
Lwan is written in C. Learn C with our recommended free books and free tutorials.
Return to Web Servers | Return to Web Caches
Popular series | |
---|---|
![]() | The largest compilation of the best free and open source software in the universe. Each article is supplied with a legendary ratings chart helping you to make informed decisions. |
![]() | Hundreds of in-depth reviews offering our unbiased and expert opinion on software. We offer helpful and impartial information. |
![]() | The Big List of Active Linux Distros is a large compilation of actively developed Linux distributions. |
![]() | Replace proprietary software with open source alternatives: Google, Microsoft, Apple, Adobe, IBM, Autodesk, Oracle, Atlassian, Corel, Cisco, Intuit, SAS, Progress, Salesforce, and Citrix |
![]() | Awesome Free Linux Games Tools showcases a series of tools that making gaming on Linux a more pleasurable experience. This is a new series. |
![]() | Machine Learning explores practical applications of machine learning and deep learning from a Linux perspective. We've written reviews of more than 40 self-hosted apps. All are free and open source. |
![]() | New to Linux? Read our Linux for Starters series. We start right at the basics and teach you everything you need to know to get started with Linux. |
![]() | Alternatives to popular CLI tools showcases essential tools that are modern replacements for core Linux utilities. |
![]() | Essential Linux system tools focuses on small, indispensable utilities, useful for system administrators as well as regular users. |
![]() | Linux utilities to maximise your productivity. Small, indispensable tools, useful for anyone running a Linux machine. |
![]() | Surveys popular streaming services from a Linux perspective: Amazon Music Unlimited, Myuzi, Spotify, Deezer, Tidal. |
![]() | Saving Money with Linux looks at how you can reduce your energy bills running Linux. |
![]() | Home computers became commonplace in the 1980s. Emulate home computers including the Commodore 64, Amiga, Atari ST, ZX81, Amstrad CPC, and ZX Spectrum. |
![]() | Now and Then examines how promising open source software fared over the years. It can be a bumpy ride. |
![]() | Linux at Home looks at a range of home activities where Linux can play its part, making the most of our time at home, keeping active and engaged. |
![]() | Linux Candy reveals the lighter side of Linux. Have some fun and escape from the daily drudgery. |
![]() | Getting Started with Docker helps you master Docker, a set of platform as a service products that delivers software in packages called containers. |
![]() | Best Free Android Apps. We showcase free Android apps that are definitely worth downloading. There's a strict eligibility criteria for inclusion in this series. |
![]() | These best free books accelerate your learning of every programming language. Learn a new language today! |
![]() | These free tutorials offer the perfect tonic to our free programming books series. |
![]() | Linux Around The World showcases usergroups that are relevant to Linux enthusiasts. Great ways to meet up with fellow enthusiasts. |
![]() | Stars and Stripes is an occasional series looking at the impact of Linux in the USA. |