From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id B2B7EBBAF for ; Mon, 26 Jul 2010 00:24:45 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjYCANZWTExDww+pkGdsb2JhbACDFI9VjQwBAQEBCQkMBxEDH68CO4IQhFGJAgEEBAGBIYMdcwSECA X-IronPort-AV: E=Sophos;i="4.55,259,1278280800"; d="scan'208";a="64391701" Received: from web111507.mail.gq1.yahoo.com ([67.195.15.169]) by mail1-smtp-roc.national.inria.fr with SMTP; 26 Jul 2010 00:24:44 +0200 Received: (qmail 57197 invoked by uid 60001); 25 Jul 2010 22:24:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1280096683; bh=eIfD/U3alz6Qn/SnIYxerOGxyQYPalFhqXEk12KgivY=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=qTdOnbPA5ct+oJBJ/TSsWZkfwwzHaANaXSKq8z+Y43f7LXaWWTejdEsyg8hFvfzdqKWNBcu2Yjg8pDMbvQ+IpYiVf/dPj1yrneWMxyeEJvPoru0e2kuxC/wgEiDCnu60IGc+Zk/aqGGplZ71eqT93FvbEVfc24mUJxVB2OSL3mE= DomainKey-Signature:a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=RqWL1Yk0ZGm7GEW1jOHlUFgJHJ/kaEpYJVJKbT4VSAurFSOmQgOtPAT6qDiUqiDXH+uUD48Wtx/5+Zdcc0nEBCVq3cGvaNwCwiVyO1DxWxBjecDxBQc9xqfvO1Col3VjJCM3nqC2APCX3WJObSGnPhBNAKKDIBaTc53GB3JbKY8=; Message-ID: <362124.56006.qm@web111507.mail.gq1.yahoo.com> X-YMail-OSG: h3mMkkIVM1kLmOKveEHKLAbxheUDN.eOa_goT1KgstQ5vOM sj6PQSAU1o3vYBtiLmp7uxcBFziGWviNol6Q6.FiSy9epb4YOOKITY8iLhWH 4dL9kI1__sEtktHr67nni..sTm8vDtnnHc3uyrvbh9Xx3rgcA0dE04YbZjbj MMALMWcld97df5V86xkezxBAa.ZGnsW7gc0huEsccRA5wM_5dMz056VrkmVN F4mHxFB82Ng4jHCQYi.ar5ZQWBTOB1wLSxEY1SicbLLQA9C6caSsTtmJ_RxM D2pyrP1t5bXG.sk5Fdxe3FlQXtksXXhWxtiOQv5b5nLIAOUYJxiSdiwm4p6C MsMJqtiC1xmQrHSM- Received: from [213.205.71.53] by web111507.mail.gq1.yahoo.com via HTTP; Sun, 25 Jul 2010 15:24:43 PDT X-Mailer: YahooMailClassic/11.2.4 YahooMailWebService/0.8.105.277674 Date: Sun, 25 Jul 2010 15:24:43 -0700 (PDT) From: Dario Teixeira Subject: Re: [Caml-list] scalable web apps To: Joel Reymont Cc: caml-list@yquem.inria.fr In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; scalable:01 bindings:01 bindings:01 monadic:01 low-level:01 cheers:01 threads:01 caml-list:01 data:02 module:03 latter:03 asynchronous:03 apps:04 problem:05 problem:05 Hi,=0A=0A> How does Ocsigen handle database operations?=0A> I assume they n= eed to be asynchronous because of=0A> lightweight threads (Lwt).=0A=0AOcsig= en itself is agnostic on DB matters. However, your assumption=0Aconcerning= the Lwt-friendliness of the DB layer is correct. There's=0Abasically two = solutions to this problem: 1) Use whatever DB bindings=0Ayou prefer, but wr= ap them under Lwt_preemptive; 2) Use Lwt-aware DB=0Abindings. For the latt= er the usual recommendation is PG'OCaml [1],=0Awhich in its current incarna= tion can be used in a monadic fashion=0A(with Lwt, for example). If you wa= nt to interact with the DB at=0Aan even higher level there's also Macaque [= 2], which is part of=0Athe Ocsigen project (note that Macaque relies on PG'= OCaml for the=0Alow-level work).=0A=0AWhen using PG'OCaml with Lwt, pretty = soon you'll come across the=0Aproblem of connection pooling. This is the m= oment you'll want to=0Alook into Lwt_pool, which makes this task a breeze.= =0A=0AFinally, if you're looking for a concrete example of all this stuff= =0Aput together I suggest taking a look at the Lambdium's database.ml=0Amod= ule [3] (you can find it under 'backend/src/data/').=0A=0AHope that's enoug= h to get you going...=0ACheers,=0ADario Teixeira=0A=0A[1] http://pgocaml.be= rlios.de/=0A[2] http://ocsigen.org/macaque/=0A[3] https://forge.ocamlcore.o= rg/projects/lambdium/=0A=0A=0A=0A