Multiple Noir Apps on One Server

118 views
Skip to first unread message

Bahman Movaqar

unread,
Sep 20, 2012, 9:27:34 PM9/20/12
to clj-...@googlegroups.com
Hi all,

I need to run *multiple* instances of *one* Noir app on *one* server.  What is
the recommended way to do so?  How do you people deal with this in real world?

1.  Run multiple “uberjar”s on different ports?  (OT but in this case is it
possible to have Apache or Nginx map ports to different IP/domains?  For
example:
   8080 -> www.example1.com
   8081 -> www.example2.com
   8082 -> www.example3.com/app

2.  Run multiple “uberwar”s with different context paths on Tomcat? Is it
possible at all?  I searched a lot but couldn't come to a conclusion that if I
can deploy Noir apps in non-root context roots or not and if yes, how.

Thanks in advance,

--
Bahman

Mark Rathwell

unread,
Sep 20, 2012, 9:41:15 PM9/20/12
to clj-...@googlegroups.com
Don't have time to get in depth right now, but in short, yes, both 1
and 2 are possible. #2 is going to be much more involved, so if you
are okay with #1, probably better to go that route. Search on
'reverse proxy' for nginx or apache for the configuration.

Chris Granger

unread,
Sep 20, 2012, 9:48:31 PM9/20/12
to clj-...@googlegroups.com
fwiw, I do #1 for everything I have live. Reverse proxying has worked out really well/

Cheers,
Chris.

Bahman Movaqar

unread,
Sep 22, 2012, 12:10:03 AM9/22/12
to clj-...@googlegroups.com
Thanks Chris and Mark.

--
Bahman

Jim Crossley

unread,
Sep 26, 2012, 2:52:45 PM9/26/12
to clj-...@googlegroups.com
Hi Bahman,

Bahman Movaqar <b.mo...@gmail.com> writes:

> I need to run *multiple* instances of *one* Noir app on *one* server.
> What is the recommended way to do so? How do you people deal with this
> in real world?

This is actually a great use case for Immutant! :)

By default on Immutant, applications are mounted at a context path
corresponding to the name from project.clj. But you can override this
with the --name option:

$ cd /where/your/app/is
$ lein immutant deploy --name example1
$ lein immutant deploy --name example2
$ lein immutant deploy --name example3

So your single app would be available at the following URL's:

http://localhost:8080/example1
http://localhost:8080/example2
http://localhost:8080/example3

The --name option is what allows you to deploy the same app multiple
times, but the --context-path and --virtual-host options give you even
more control.

For example, you can mount all three apps at the root context as long as
you bind them to different virtual hosts, e.g.

$ lein immutant deploy --context-path / --virtual-host example1.com

This would have your app available at the following URL's:

http://example1.com:8080
http://example2.com:8080
http://example3.com:8080

There are no uber(j|w)ars to create. Immutant deploys your app from
where it sits on disk. This is handy for development, but not in
production. So there you can pass the --archive option to create an
archive, or use the plugin's archive task.

Once deployed, you now have only a single process to manage (and
hopefully better memory utilization): when you start up Immutant, it'll
mount all your apps at whatever virtual hosts and/or context paths you
specified when you deployed them. If you change your mind, just
redeploy.

Drop in #immutant on freenode if you have any questions.

Good luck!
Jim

Bahman Movaqar

unread,
Sep 27, 2012, 8:18:35 AM9/27/12
to clj-...@googlegroups.com
On 09/26/2012 10:22 PM, Jim Crossley wrote:
> Hi Bahman,
>
> Bahman Movaqar <b.mo...@gmail.com> writes:
>
>> I need to run *multiple* instances of *one* Noir app on *one* server.
>> What is the recommended way to do so? How do you people deal with this
>> in real world?
> This is actually a great use case for Immutant! :)

Sure it is. Immutant was one of the solutions that caught my attention
when searching and I really liked its idea.

You may be wondering why I'm not using it. Well, I have a VPS and -as I
said earlier- am planning to host multiple clients on it. The problem
is that it has only 512MB RAM (can't afford more right now) and the name
of JBoss alone, on Immutant website was more than enough to scare me off :-)

However, I'm no JBoss expert. Please correct my assumption about JBoss'
memory consumption if I'm wrong.
Thanks for the detailed description. I will definitely give Immutant a
serious go in near future.

>
> Good luck!
> Jim
>
>> 1. Run multiple “uberjar”s on different ports? (OT but in this case is it
>> possible to have Apache or Nginx map ports to different IP/domains? For
>> example:
>> 8080 -> www.example1.com
>> 8081 -> www.example2.com
>> 8082 -> www.example3.com/app
>>
>> 2. Run multiple “uberwar”s with different context paths on Tomcat? Is it
>> possible at all? I searched a lot but couldn't come to a conclusion that
>> if I
>> can deploy Noir apps in non-root context roots or not and if yes, how.
>>
>> Thanks in advance,
>>
>> --
>> Bahman

--
Bahman Movaqar (http://BahmanM.com)

ERP Evaluation, Implementation & Deployment Consultant
PGP Key ID: 0x3310C346 (kerserver2.pgp.com)


signature.asc

Jim Crossley

unread,
Sep 27, 2012, 8:52:59 AM9/27/12
to clj-...@googlegroups.com
Hi Bahman,

Bahman Movaqar <b.mo...@gmail.com> writes:

> On 09/26/2012 10:22 PM, Jim Crossley wrote:

[...]

>> This is actually a great use case for Immutant! :)
>
> Sure it is. Immutant was one of the solutions that caught my attention
> when searching and I really liked its idea.
>
> You may be wondering why I'm not using it. Well, I have a VPS and -as
> I said earlier- am planning to host multiple clients on it. The
> problem is that it has only 512MB RAM (can't afford more right now)
> and the name of JBoss alone, on Immutant website was more than enough
> to scare me off :-)

Haha! :)

> However, I'm no JBoss expert. Please correct my assumption about JBoss'
> memory consumption if I'm wrong.

AS7 is far leaner and faster and smarter about only loading what you use
at runtime than its ancestors. From a cold start, it's even smaller than
Jetty, according to this guy:
http://plumbr.eu/blog/who-is-stealing-your-memory-the-application-servers-edition

If you're only deploying one app, Jetty is the way to go. But one AS7
process with three apps deployed should use less RAM than three
Jetty processes.

You could also create uberwars and deploy them to a single Jetty or
Tomcat process, but I doubt your memory util will be much better than
Immutant (or else wtf are we doing, right!?), and even if slightly
higher, the simpler deployment on Immutant warrants that tradeoff, imho.

Choose what's best for you, but don't rule out Immutant based on
preconceived notions about turn-of-the-century, bloated app servers.
That'd be like dismissing Clojure because it's a Lisp! ;-)

Jim
0 new messages