I want to write a web services server (using the http protocol) in OCaml.
For a simple example, I want to write http server . The user can access it and provide a parameter of the type http://myservice.com?i=1&j=2 . Then my server will receive 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 calculation example, what I really need to do is
- database access (MongoDB) to retrieve data
- Access another third-party web service for more data.
- calculate all the data to get the result and return to the user.
So, I also need to consider parallelism / multi-threading , although first I want to start with a simple case.
My questions:
- What library should I use to set up such an
http server ? I reviewed Ocamlnet 3 and think it might be a good candidate, but it lacks a good tutorial, and I still don't know how to use nethttpd or netplex , etc. - How do I build my web application architecture ? I know that OCaml is not suitable for
parallelism , then how can I make each service instance not block?
source share