addressalign-toparrow-leftarrow-rightbackbellblockcalendarcameraccwcheckchevron-downchevron-leftchevron-rightchevron-small-downchevron-small-leftchevron-small-rightchevron-small-upchevron-upcircle-with-checkcircle-with-crosscircle-with-pluscrossdots-three-verticaleditemptyheartexporteye-with-lineeyefacebookfolderfullheartglobegmailgooglegroupshelp-with-circleimageimagesinstagramFill 1linklocation-pinm-swarmSearchmailmessagesminusmoremuplabelShape 3 + Rectangle 1ShapeoutlookpersonJoin Group on CardStartprice-ribbonprintShapeShapeShapeShapeImported LayersImported LayersImported Layersshieldstartickettrashtriangle-downtriangle-uptwitteruserwarningyahoo

Re: [ljc] java concurrency in web apps

From: Ion I.
Sent on: Thursday, March 7, 2013 4:35 PM
Hi Jim


I think you are right. I don't think this is in the specifications. But, many other best practices are not.

Also, when I say that you shouldn't spawn threads in a normal application, I also mean the service layer servers, not just the front-end ones. Of course there are applications out there for which it is better to create threads, but, in my opinion, for the majority of them, doing it is a bad practice.


Regards,
Ion

www.ionionascu.eu


On Thu, Mar 7, 2013 at 4:28 PM, Jim Collins <[address removed]> wrote:
Hi Ion,

I can appreciate that could cause problems with a load balancer and ultimately the web layer is not the best place to run compute expensive long running tasks. Although it is a while since I looked at the specs I never saw anything that said you should not create new threads in a web app though. 

Regards

Jim 

On 7 March[masked]:07, Ion Ionascu <[address removed]> wrote:
Hi Jim,


The problem is resource management. A long running job should be put in queue and it should be run based on some pre-defined rules.

For example, how do you exact for a load balancer to correctly dispatch jobs to the nodes in a cluster when it doesn't know the correct load on each of them?


Regards,
Ion

www.ionionascu.eu


On Thu, Mar 7, 2013 at 11:36 AM, Jim Collins <[address removed]> wrote:
What is so wrong with introducing concurrency in a web app? If the Servlet request has to make some potentially long running call then it makes sense to have a policy for dealing with this so subsequent requests do not block.

On 7 March[masked]:55, Ged Byrne <[address removed]> wrote:
Hi John,

You open yourself to a whole world of pain once you introduce concurrency.  If you can avoid it then you should. 

If there is an unavoidable need for concurrency then you might want to consider using Camel.  Then you are managing queues rather than threads, which is much easier.  

Regards,



Ged







On Wednesday, 6 March 2013, Jon Hatfield wrote:
Hi all,

I have heard many times "do not create threads in a web app", since the container should manage them. However, the more modern APIs such as ExectorService appear to be used in web apps by some people. Can you use such java.util.concurrent classes in a wep app that requires multi-threading (e.g. due to high load), or do you forward data to a stand alone app that deals with the multi-threading? I can't find a definite answer on the internet.

Regards,
Jon

Our Sponsors

  • Our Blog

    Read the latest news from the LJC

  • RecWorks Ltd

    Fixing Tech Recruitment using the Power of Community

  • jClarity

    Java/JVM Performance Analysis Tools & mentoring for Java related matters

  • LJC Aggrity

    Our LJC Aggrity site contains blog posts from our members

  • LJC Book Club

    Our Book club with book reviews from our members

  • Devoxx UK

    Java Community Conference in collaboration with the LJC, 8-10th June 16

  • SkillsMatter

    "Host, help organise, promote, film many of our meetings."

  • IBM

    Build Enterprise-grade apps at start-up speed.

  • New Relic

    New Relic makes sense of billions of metrics a day in real time.

  • Hazelcast

    Hazelcast is the leader in operating in-memory computing.

  • Java.Net

    We are an official Java User Group recognised by Oracle's JUG program

  • JRebel

    Free 3 month J-Rebel license.

  • O'Reilly

    40% discount on printed books and 50% on e-books.

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy