'How to write a web server (service) in OCaml? [closed]

I wish to write a web service server (using http protocol) in OCaml.

For a simple example, I want to write a http server. User can access it and provide parameter like http://myservice.com?i=1&j=2. Then my server get the request and parameters and calculate i+j and return the result.


Of course, my service will be more complicated for the calculation part. Instead of this simple example of calculation, what I really need to do is to

  1. access the database (MongoDB) to get some data
  2. access another 3rd party web service to get more data
  3. calculate all data to get a result and return to the user.

So, I also need to consider parallelism / multi-threading, although I want to start with simple case first.


My questions are:

  • Which library should I use to first set up such a http server? I have looked into Ocamlnet 3 and think it might be a good candidate, but it lacks good tutorial and I still don't know how to use nethttpd or netplex etc.
  • How should I design the architecture of my web application? I know OCaml is not good at parallelism, then how can I make each service instance not blocking?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source