Reputation: 53940
I want to learn more Erlang, and as a playground, I want to use it for core backend logic.
I wonder, if for connecting with end users I should choose another stack, like NodeJS and connect it somehow to Erlang?
Say, I want to make websocket connections to users with NodeJS, as it's perfectly suitable for WebSockets, and then create a communication between NodeJS and Erlang to pass all the data-crunching to Erlang, while keep NodeJS as a middleman between backend and end users.
Should I use a middleman technology at all or is it a good solution to put Erlang + Apache/nginx and implement the whole system using Erlang?
Upvotes: 2
Views: 288
Reputation: 5500
Erlang's main strength is exactly this handling of client connections and routing requests to workers. The lightweight and isolated processes makes it scale very well to large number of connections while making it very error tolerant. Erlang is typically not the right language for heavy number crunching, it should be used for request handling and routing.
So instead of putting something like node.js as the connection handler and router just use e.g. Yaws or Cowboy (more popular choice currently) as the websocket server and handle everything in Erlang.
In a production system you could use nginx/haproxy as a load-balancer/proxy in front of the Erlang server, but not necessary in any way.
An interesting article on Erlang server scalability is A Million-user Comet Application with Mochiweb, it's about comet-style HTTP requests, not web sockets, but has a lot of good information.
Upvotes: 1