caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Anil Madhavapeddy <anil@recoil.org>
To: Jake Donham <jake@donham.org>
Cc: Jon Harrop <jon@ffconsultancy.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Asynchronous IO programming in OCaml
Date: Sun, 24 Oct 2010 13:54:50 -0700	[thread overview]
Message-ID: <A7C6ED92-10BA-444B-A381-FC6AB7666932@recoil.org> (raw)
In-Reply-To: <AANLkTikgf2qF4y=o+S8PYUxZoCrCG-TRcovUq8uB=y7k@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

On 24 Oct 2010, at 09:17, Jake Donham wrote:

> On Sun, Oct 24, 2010 at 3:34 AM, Jon Harrop <jon@ffconsultancy.com> wrote:
> Is there a tutorial on using something like LWT for asynchronous programming
> in OCaml? I'm looking for an example like an echo server that handles
> clients concurrently without blocking threads, so it can handle thousands of
> clients without significant performance degradation.
> 
> Not a tutorial, but here is a minimal TCP server in LWT:
> 
>   http://github.com/avsm/ocaml-cohttpserver/blob/master/server/http_tcp_server.ml

This should work fine for a couple of thousand clients or so, but you'll begin to see degradation as the number of clients increase. This is because LWT internally uses select(2) to wait for file-descriptors, and not the newer kqueue(2) or epoll(2) interfaces. You can read more about the "C10K problem" here: http://www.kegel.com/c10k.html

I've got a stripped-down version of LWT that uses these newer event-driven kernel interfaces (and so should be able to cross the 10,000 client barrier fairly easily), but it won't be ready for release for another month or so.  Drop me an email off-list if you want to try it out earlier.

Async disk I/O under Linux is annoyingly problematic if you aren't using direct I/O (and hence page/block-aligned structures). Avoid if possible :)

Anil

[-- Attachment #2: Type: text/html, Size: 2244 bytes --]

  reply	other threads:[~2010-10-24 20:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-24 10:34 Jon Harrop
2010-10-24 12:51 ` [Caml-list] " philippe
2010-10-24 12:52 ` Dario Teixeira
2010-10-24 16:33   ` oliver
2010-10-24 18:50     ` Dario Teixeira
2010-10-24 19:04       ` bluestorm
2010-10-24 20:02       ` oliver
2010-10-24 21:51     ` Michael Ekstrand
2010-10-24 16:17 ` Jake Donham
2010-10-24 20:54   ` Anil Madhavapeddy [this message]
2010-10-24 22:50     ` Jérémie Dimino
2010-10-25  3:42       ` Markus Mottl
2010-10-25  7:49         ` Richard Jones
2010-10-25  8:42       ` Goswin von Brederlow
2010-10-25 11:10         ` Jérémie Dimino
     [not found]           ` <AANLkTimP77PDEChW3Yt6uUy_qxYpj6EOZWQ_==id-LBC@mail.gmail.com>
     [not found]             ` <20101025143317.GB32282@aurora>
2010-10-25 15:34               ` Yaron Minsky
2010-10-25 17:26                 ` Jérémie Dimino
2010-10-27  9:33                   ` Goswin von Brederlow
2010-10-27 11:18                     ` Jérémie Dimino
2010-10-27 13:43                       ` Goswin von Brederlow
2010-10-27 15:30                         ` Jérémie Dimino
2010-10-28  9:00                           ` Goswin von Brederlow
2010-10-28  9:28                             ` Jérémie Dimino
2010-10-28 10:11                               ` Goswin von Brederlow
2010-10-25 15:58           ` DS
2010-10-24 20:42 ` Goswin von Brederlow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=A7C6ED92-10BA-444B-A381-FC6AB7666932@recoil.org \
    --to=anil@recoil.org \
    --cc=caml-list@yquem.inria.fr \
    --cc=jake@donham.org \
    --cc=jon@ffconsultancy.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).