FAQ
This may not be a Clojure specific kind of question, but this is for
my Clojure web app(s) so hopefully it's not too far off.

Currently when I deploy my web apps I run 1 app instance on 1 app
server. Given these are multi-core servers I am thinking about running
4 app instances on a server to get max IO capabilities at a lower
cost. (Note that I currently using nginx, to route requests to a
Clojure/Ring+Jetty web app on a specified port. I am expecting that in
order to run 4 app instances I will need to load balance within nginx
to each port and also set the processor affinity for each app instance
to ensure they are balanced across cores).

So here are my questions:

1. Does this idea make sense? why/whynot?
2. Do you do currently do this for your web apps and can you provide
any insight/experiences that could be helpful?
3. Is there a way to specify processor affinity within the
application, such that I wouldn't need to manually set them
afterwards?
4. Are there better ideas to accomplish the same kind of thing?

Thanks for any help/ideas.

Tim



--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Search Discussions

  • Colin Yates at Oct 20, 2011 at 7:37 pm
    I don't think so. Jetty is also multi-threaded; each request will be served
    by a new thread (within a bounded thread pool). Secondly, processor
    affinity is almost always a bad idea; the OS is pretty good at doing this
    for you.

    At the very least I would have a test harness which measures the behaviour
    of the application under heavy concurrent access - I would be amazed if you
    any benefit from your approach. I wouldn't be surprised at all if it
    becomes much worse - sorry :).

    Note; I am not a performance specialist and even if I claimed to be one you
    should always take advice with a pinch of salt. It should be fairly easy to
    measure the difference between the two deployment models yourself.

    Sorry.
    On 20 October 2011 19:41, Tim Robinson wrote:

    This may not be a Clojure specific kind of question, but this is for
    my Clojure web app(s) so hopefully it's not too far off.

    Currently when I deploy my web apps I run 1 app instance on 1 app
    server. Given these are multi-core servers I am thinking about running
    4 app instances on a server to get max IO capabilities at a lower
    cost. (Note that I currently using nginx, to route requests to a
    Clojure/Ring+Jetty web app on a specified port. I am expecting that in
    order to run 4 app instances I will need to load balance within nginx
    to each port and also set the processor affinity for each app instance
    to ensure they are balanced across cores).

    So here are my questions:

    1. Does this idea make sense? why/whynot?
    2. Do you do currently do this for your web apps and can you provide
    any insight/experiences that could be helpful?
    3. Is there a way to specify processor affinity within the
    application, such that I wouldn't need to manually set them
    afterwards?
    4. Are there better ideas to accomplish the same kind of thing?

    Thanks for any help/ideas.

    Tim



    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with
    your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Andy Fingerhut at Oct 21, 2011 at 12:05 am
    I would suspect that you would not get a _significant_ performance advantage
    from specifying processor affinity, but if you really want to measure it and
    find out by experimentation, read on.

    I was not able to find any portable way within a JVM to set processor
    affinity, after some amount of Googling on the Internet about a year ago.
    There might be some ways that are specific to some JVMs, but I didn't find
    any then.

    If you want to set the processor affinity for an arbitrary process running
    on Linux, whether it is a JVM or not, you can do so with a sched_affinity()
    call in a little wrapper process that starts up the process for you.

    According to the StackOverflow discussion linked below, user tgamblin found
    that sched_affinity() semantics can vary across Linux distributions. They
    mention a Portable Linux Processor Affinity library that may be useful,
    although I haven't tried it myself. They mention that for some
    high-performance parallel applications, e.g. using the MPI library, it is
    common practice to manually specify processor affinity.

    http://stackoverflow.com/questions/360307/multicore-hyperthreading-how-are-threads-distributed

    Note that if you benchmark manually setting processor affinity vs. not, note
    that benchmarking this with programs that use very little memory (e.g. an
    infinite loop that just counts iterations) will likely not show as much
    difference as a benchmark that has significant usage of the on-chip CPU
    instruction and/or data cache, so that switching the scheduling of the
    thread to a different CPU core actually causes significant cache misses
    after being "moved".

    Andy
    On Thu, Oct 20, 2011 at 11:41 AM, Tim Robinson wrote:

    This may not be a Clojure specific kind of question, but this is for
    my Clojure web app(s) so hopefully it's not too far off.

    Currently when I deploy my web apps I run 1 app instance on 1 app
    server. Given these are multi-core servers I am thinking about running
    4 app instances on a server to get max IO capabilities at a lower
    cost. (Note that I currently using nginx, to route requests to a
    Clojure/Ring+Jetty web app on a specified port. I am expecting that in
    order to run 4 app instances I will need to load balance within nginx
    to each port and also set the processor affinity for each app instance
    to ensure they are balanced across cores).

    So here are my questions:

    1. Does this idea make sense? why/whynot?
    2. Do you do currently do this for your web apps and can you provide
    any insight/experiences that could be helpful?
    3. Is there a way to specify processor affinity within the
    application, such that I wouldn't need to manually set them
    afterwards?
    4. Are there better ideas to accomplish the same kind of thing?

    Thanks for any help/ideas.

    Tim



    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with
    your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Tim Robinson at Oct 21, 2011 at 4:35 pm
    Thank you both..
    This information was really helpful.
    Tim
    On Oct 20, 6:05 pm, Andy Fingerhut wrote:
    I would suspect that you would not get a _significant_ performance advantage
    from specifying processor affinity, but if you really want to measure it and
    find out by experimentation, read on.

    I was not able to find any portable way within a JVM to set processor
    affinity, after some amount of Googling on the Internet about a year ago.
    There might be some ways that are specific to some JVMs, but I didn't find
    any then.

    If you want to set the processor affinity for an arbitrary process running
    on Linux, whether it is a JVM or not, you can do so with a sched_affinity()
    call in a little wrapper process that starts up the process for you.

    According to the StackOverflow discussion linked below, user tgamblin found
    that sched_affinity() semantics can vary across Linux distributions.  They
    mention a Portable Linux Processor Affinity library that may be useful,
    although I haven't tried it myself.  They mention that for some
    high-performance parallel applications, e.g. using the MPI library, it is
    common practice to manually specify processor affinity.

    http://stackoverflow.com/questions/360307/multicore-hyperthreading-ho...

    Note that if you benchmark manually setting processor affinity vs. not, note
    that benchmarking this with programs that use very little memory (e.g. an
    infinite loop that just counts iterations) will likely not show as much
    difference as a benchmark that has significant usage of the on-chip CPU
    instruction and/or data cache, so that switching the scheduling of the
    thread to a different CPU core actually causes significant cache misses
    after being "moved".

    Andy

    On Thu, Oct 20, 2011 at 11:41 AM, Tim Robinson wrote:






    This may not be a Clojure specific kind of question, but this is for
    my Clojure web app(s) so hopefully it's not too far off.
    Currently when I deploy my web apps I run 1 app instance on 1 app
    server. Given these are multi-core servers I am thinking about running
    4 app instances on a server to get max IO capabilities at a lower
    cost.  (Note that I currently using nginx, to route requests to a
    Clojure/Ring+Jetty web app on a specified port. I am expecting that in
    order to run 4 app instances I will need to load balance within nginx
    to each port and also set the processor affinity for each app instance
    to ensure they are balanced across cores).
    So here are my questions:
    1. Does this idea make sense? why/whynot?
    2. Do you do currently do this for your web apps and can you provide
    any insight/experiences that could be helpful?
    3. Is there a way to specify processor affinity within the
    application, such that I wouldn't need to manually set them
    afterwards?
    4. Are there better ideas to accomplish the same kind of thing?
    Thanks for any help/ideas.
    Tim
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with
    your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en
  • Gary Trakhman at Nov 6, 2011 at 2:06 pm
    it seems like the only difference would be 4 garbage collectors working on
    smaller heaps, however there would be much more memory overhead that way.
    I assume if you can load-balance your app like that, that it is stateless,
    and won't use a whole bunch of static memory. You might do better with
    changing some performance tuning parameters. This is a great video that
    describes the tradeoffs: http://www.parleys.com/#id=2662&st=5

    --
    You received this message because you are subscribed to the Google
    Groups "Clojure" group.
    To post to this group, send email to clojure@googlegroups.com
    Note that posts from new members are moderated - please be patient with your first post.
    To unsubscribe from this group, send email to
    clojure+unsubscribe@googlegroups.com
    For more options, visit this group at
    http://groups.google.com/group/clojure?hl=en

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupclojure @
categoriesclojure
postedOct 20, '11 at 6:41p
activeNov 6, '11 at 2:06p
posts5
users4
websiteclojure.org
irc#clojure

People

Translate

site design / logo © 2022 Grokbase