An Introduction to the Yaws Webserver
“Apache dies at about 4,000 parallel sessions. Yaws is still functioning at over 80,000 parallel connections.”
While evaluating Yaws, I was really surprised when I came across these results of an experiment conducted by SICS. This experiment was conducted quite some time ago and compared the performance of Yaws vs. Apache. I am not sure under what conditions these tests were conducted, but the results were pretty interesting and compelling for anyone to go ahead and try out Yaws.
Yaws is a pretty neat web server written purely in Erlang. But, before we talk about Yaws it is important to know a little background of Erlang as well.
When I got an opportunity to work on Erlang I thought it is a new language. But, to my surprise the first version was developed by Joe Armstrong in 1986. In the recent times, people have realized its potential and Erlang is now getting the attention it deserves.
Erlang is primarily a functional language based on Actor Model to simplify concurrent programming. The Erlang code is executed inside the Erlang Virtual Machine which is very similar to a Java Runtime Environment but supports concurrency extremely well. Hundreds and thousands of lightweight Erlang processes can be spawned inside the virtual machine.
When it comes to deploying web applications the most commonly used web server in the Erlang world is Yet Another Web Server or commonly known as Yaws. Yaws is written and maintained by long time Erlang expert Claes “Klacke” Wikström. Apart from Yaws, Klacke has also contributed a lot of other important tools like the Mnesia database, distributed Erlang, the eprof profiler and many more.
The reason behind the performance and scalability of Yaws is again due to Erlang. It is written purely Erlang and every new client is handled using a light-weight Erlang process. This has a huge impact in the number of connections that Yaws can handle concurrently and scale. Each socket is just one process and there are no state machines involved where there is main event loop which dispatches events that arrive on different sockets.
Yaws can be used in multiple scenarios and the most simple of them could be serving static pages. But, if you really want to use it to its full potential then you should use it to serve dynamic content. Yaws is extremely powerful in delivering dynamic content. Most of the websites that are build today serve dynamic content with Ajax and Yaws is very efficient in serving these types of requests.
Although, the name Yet Another Web Server may give you an impression that Yaws is just a web server. But, it is actually a lot more than that. When you want to serve dynamic content, Yaws is a complete package that is an alternative to the classic setup of PHP, MySQL and Apache. The server part of it is handled by Yaws, Mnesia handles the database part and the dynamic content is served using Erlang.
Yaws has all the features that can be expected from a modern day web server. It can be used in two different modes.
Standalone mode: This is the default mode where it can be used as a regular web server.
Embedded Mode: Where it can be embedded and used within another Erlang applications that need the functionality of a web server.
It may be a little disheartening, but to use Yaws you will have to learn Erlang. If you have not programmed in a functional language before it could be a little difficult to learn. But, the advantages are enormous and I strongly suggest that if you get a chance you should definitely try your hands on it.
In my next blog I will share, how can you can install and get started with using Yaws.
1 Comment for this post
Posted by Ramesh Krishnan | Jun 15, 2010
I started evaluating Yaws recently for one of my projects and was pretty excited to see the results. Thanks for this great insight on yaws and this gives me the confidence that I’m moving in the right direction.
Looking forward for your future posts.
Thanks again.
Ramesh
prkarve
An Introduction to the Yaws Webserver Mar 10, 2010sdutta
Social Networking – Myths and Facts Jul 06, 2010cgangwal
Why Software Testing Has Become Need of the Hour Sep 23, 2011vgupta
Scrum beyond Software Dec 09, 2011prkarve
Does Big Data and Social Media Analytics go hand in hand? Oct 31, 2011jtrehan
Think innovation first! Sep 27, 2010pmittal
|
|
||||||||
More
|
More
|
More Videos ![]() |



Post a Comment