The free world is the new continent in cyberspace that we have built so we can live here in freedom. It's impossible to live in freedom in the old world of cyberspace, where every program has its feudal lord that bullies and mistreats the users. So, to live in freedom we have to build a new continent. Because this is a virtual continent, it has room for everyone, and there are no immigration restrictions. - Richard Stallman -

Yaws (Yet another web server) is a web server written in Erlang by Claes (klacke) Wikström.

Yaws can be embedded into other Erlang-based applications or run as a regular standalone web server.

Because Yaws uses Erlang's lightweight threading system, it performs well under high concurrency.

A load test conducted in 2002 comparing Yaws and Apache found that with the hardware tested, Apache 2.0.39 with the worker MPM failed at 4,000 concurrent connections, while Yaws continued functioning with over 80,000 concurrent connections.

Last stable relase: 1.87 (2010-01-05)

Two separate modes of operations are supported.

* Standalone mode where Yaws runs as a regular webserver daemon. This is the default mode. * Embedded mode where Yaws runs as an embedded webserver in another erlang application.

Updates:

* websocket support (davide and wde) * conditional compile of websockets, only use if the chosen erl supports it (klacke/steve) * patch by Andrei Soroker to strip the port part in #redir_self records - this patch may break some code, users that use redir_self() and unconditionally strip off their optional port number are affected * support some extra status codes in code_to_phrase (steve) * drop spaces before parsing ints - patch by Colm Dougan * proper handling of "/" appmod with excluded paths (patch from wde) * Added new unit tests for appmods, with both / and non-/ tests. The / tests include exclude_paths testing. (steve) * patch from wde solving a problem with appmod exclude paths and verify_upgrade * yaws_server: fixed the test for whether to close the socket. The yaws:outh_get_doclose() doesn't return a boolean and it requires the outh dicionary entry to be set (sometimes it isn't). (davide) * do not pass the --id option if the default id is used (steve)

Let us not forget the famous comparison between Yaws and Apache. In a denial of service attack, the number of parallel connections needed to crash the Erlang web server was about 20 times as many as an Apache web server running on the same hardware. Apache (blue and green) dies when subject to a load of concurrent 4,000 parallel requests. Yaws (red) works till 80,000 concurrent requests.

I will try to give you a simple example about how to create a simple dynamic web page with Yaws.

Thanks to Yariv Sadan’s effort to involve Erlang in the web development community using ErlyWeb which is a web framework that helps you easily build database-driven applications using the MVC architecture. It's similar to Ruby on Rails, except that it's written in Erlang. There is also ErlyDB a database abstraction layer generator. ErlyDB taps into Erlang’s runtime metaprogramming powers to generate an abstraction layer for your database on the fly.

I am going to propose an architecture for web development using Erlang. It will consists of five layers:

* Hardware/ Operating System: This layer represents the physical layer of the system. It can be a Linux system running on a network file system(NFS) to make use of the concurrency and distribution features in Erlang. * DBMS: This layer represents the persistence layer of the system. It can be either Mnesia or MySQL. * Data Base Abstraction Layer. * Erlang/Open Telecom Platform: It is the standard libraries of the Erlang language. * Presentation Layer: This layer consists of two components. Yaws as a web server and ErlyWeb as rapid development framework.

If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog: