mochi / mochiweb

MochiWeb is an Erlang library for building lightweight HTTP servers.
Other
1.86k stars 474 forks source link

Binding to multiple ports #163

Closed broerse closed 8 years ago

broerse commented 8 years ago

It would be nice if CouchDB could be served bind to multiple ports. Is that doable? See also:

https://mail-archives.apache.org/mod_mbox/couchdb-couchapp/201511.mbox/%3CCAHdjip+-iu8XRJLrHLMNuyEPEfscU0Umowm0kpw4JTx+ExTaWA@mail.gmail.com%3E

etrepum commented 8 years ago

That person is incorrect. There's no such limitation. mochiweb has no global configuration, each server is configured independently and you can run arbitrarily many of them on a given erlang node.

broerse commented 8 years ago

@etrepum Have to think about this. What you are saying is you can run 2 servers if you want to bind on 80 and 5984. Alexander seems to be saying there is only 1 server that can't bind to 2 ports.

mworrell commented 8 years ago

In zotonic we run multiple mochiweb instances, each on their own port, to handle SSL traffic. There is indeed no limitation in mochiweb, just start multiple servers, each on their own port.

kxepal commented 8 years ago

I didn't think about nodejs-way to handle this problem, but about some acceptor that can bind on IP-port pair and work with a single web server instance.

etrepum commented 8 years ago

mochiweb doesn't even have the concept of a "web server instance", the "web server instance" is your Erlang node. mochiweb_http processes are the acceptors that spawn off workers to run the given loop function per connection. If you start more than one mochiweb_http process on the same node with the same loop function but on different ports this is indistinguishable from having a "web server instance" that is listening on more than one port.

kxepal commented 8 years ago

@etrepum Good to know! Thanks for the explanation, that makes a sense.