Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell as a highly concurrent server

Let's say I want to write a server in Haskell. The kind that has high concurrency and simple processing. The kind that would be robust to failures and offer high availability. The kind that Erlang would be good for.

What would be a good set of tools, whether a framework or a set of primitives, to start from?

like image 942
me2 Avatar asked Feb 26 '10 01:02

me2


2 Answers

This is precisely what Haskell is great at. And it has excellent multicore parallelism support, so when you use more threads, you can take advantage of extra cores easily. Remember though, Haskell's aimed at great performance on multicore, Erlang's a bit different, emphasising distributed systems more, and not so much raw performance (e.g. see the benchmarks game, http://benchmarksgame.alioth.debian.org/u64q/compare.php?lang=ghc&lang2=hipe The Haskell's almost always much faster and uses much less memory).

Now, to get started:

  • You can start with the examples in Real World Haskell, to learn about forkIO and Haskell's lightweight threads, http://book.realworldhaskell.org/read/concurrent-and-multicore-programming.html

  • GHC's docs on the concurrency tools, http://haskell.org/haskellwiki/GHC/Concurrency

  • The library to look at for massive, scalable network code is the event library: http://github.com/tibbe/event which makes it easy to use epoll as the method for accepting events from the network. Here's a simple example: http://donsbot.wordpress.com/2010/01/17/playing-with-the-new-haskell-epoll-event-library/

  • For back to basics, see Simon Marlow's tutorial on building a concurrent web server: http://www.haskell.org/~simonmar/bib/webserverjfp_abstract.html

You should find this task relatively easy, and fun!

like image 166
Don Stewart Avatar answered Nov 08 '22 07:11

Don Stewart


Great place to start is the seminal paper by Simon Peyton Jones The Awkward Squad.

... I recently heard a talk you might find relevant. See details at the galois website

like image 26
Kevin Won Avatar answered Nov 08 '22 07:11

Kevin Won