[erlang-questions] Deploying multiple webapps
Hugo Mills
hugo@REDACTED
Wed Dec 16 21:25:09 CET 2015
Thanks for the reply.
On Wed, Dec 16, 2015 at 12:17:50AM +0000, Chandru wrote:
> On 16 December 2015 at 00:10, Hugo Mills <hugo@REDACTED> wrote:
>
> > Hi, Chandru,
> >
> > On Tue, Dec 15, 2015 at 11:57:56PM +0000, Chandru wrote:
> > > Why does all this have to be done in Erlang?
> > >
> > > It sounds like your best bet is to use something like
> > nginx/varnish/haproxy
> > > (or even Apache as you explained) to front your server farm. You can get
> > > that component to then rewrite the URLs and route requests to wherever
> > your
> > > Erlang web services are located. I would do that rather than trying to do
> > > everything in Erlang.
> >
> > Thanks for the advice.
> >
> > I guess I'm unhappy (probably with no good reason) with the idea of
> > running each service in a separate erlang VM, and each one running on
> > a separate port, and having to ensure that those ports aren't visible
> > outside the machine (because they'll be running HTTP, not the desired
> > HTTPS).
> >
>
> Sorry, I don't think I explained clearly. My point was that you can run
> multiple services in a single VM, on a single port. When your HTTPS request
> hits your front-end (nginx/varnish/apache/whatever), you get it to do two
> things.
> - Handle all the TLS stuff
> - Rewrite the URL in the request. (If the request from the client is
> http://server.me/service1, rewrite it to http://internal.server1.me/service1,
> http://server.me/service2 becomes
> http://internal.server1.me/service2)
OK, I'm happy with all of that as an idea.
> - You can have a global cowboy handler (one module which is used in all
> your backend erlang nodes) which provides internal routing for all your
> services. At its most basic form, routing in cowboy is redirecting requests
> based on URL to a module. So you just have to make sure this module is
> common across all your erlang nodes, regardless of how you distribute your
> services across nodes.
So I make sure that I have a 'common_routing' (or whatever) module
in each service -- do those have their own router (for the internal
routing within each service) in each one?
I guess that's something that Loïc's work with Cowboy and RabbitMQ
would help with.
> What am I missing here?
It's probably what I'm missing...
How do I handle deploying this? I really don't want to be building
a different release for each configuration, so how do I enable/disable
the different services in each separate deployment? How do I make sure
that the unused services don't run when the release is run, and don't
have routing entries in the top-level router? (Ideally, not shipping
the unused code at all, but if I'm building a single release, I guess
that's not going to be possible).
Hugo.
> > >
> > > On 15 December 2015 at 23:41, Hugo Mills <hugo@REDACTED> wrote:
> > >
> > > > I've got a collection of small services, with minimal coupling
> > > > between the back ends of those services (orchestration is done mostly
> > > > client-side). I'd like to put an HTTPS interface in front of each one
> > > > -- say, with cowboy.
> > > >
> > > > What I'd also like to be able to do, at least in principle, is
> > > > deploy some arbitrary subset of those services on each machine in my
> > > > (comedically-named) server farm. I'd like to be able to do this with
> > > > one TLS configuration, and preferably under a single port.
> > > >
> > > > i.e., access my services through
> > > >
> > > > https://server.me/service1/...
> > > > https://server.me/service2/...
> > > > https://server.me/service3/...
> > > >
> > > > Now, in python-land, which is largely where I come from, I'd set up
> > > > Apache with mod-wsgi, and deploy each WSGI app to a specific URL
> > > > within the same URL namespace. I'm not quite sure how to do that
> > > > easily with erlang+cowboy, because there seems to be no easy way of
> > > > treating a webapp as a unit within a larger server configuration. I
> > > > keep coming to one of two approaches:
> > > >
> > > > 1) Write each service completely independently (as HTTP), run it on a
> > > > distinct port, and splice together the URL namespaces through a
> > > > reverse proxy on a "normal" web server like Apache.
> > > >
> > > > 2) Find some way to automatically write a top-level router for cowboy,
> > > > for each set of services that I want to deploy to a machine.
> > > >
> > > > I don't much like option 1, but I like option 2 even less. I guess
> > > > I could write some kind of "top-level" app that, given a bunch of
> > > > webapp modules (via a configuration file of some kind), gets a router
> > > > for each module and transforms those routers into a single router
> > > > config. Does such a thing already exist?
> > > >
> > > > It all just feels a bit awkward, and I feel like I'm missing
> > > > something. What do other people do to put together this kind of setup?
> > > >
> > > > Hugo.
> > > >
> >
--
Hugo Mills | Beware geeks bearing GIFs
hugo@REDACTED carfax.org.uk |
http://carfax.org.uk/ |
PGP: E2AB1DE4 |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20151216/7bf78d7a/attachment.bin>
More information about the erlang-questions
mailing list