SlideShare uma empresa Scribd logo
1 de 74
Baixar para ler offline
JAVA EE CONCURRENCY MISCONCEPTIONS
Haim Yadid, Performize-IT Ltd.
Daniel Pfeifer, Whistler AB
Daniel Pfeifer

‣ Founder of
Performize-IT Ltd.
‣ 18+ years in
technology
‣ Primary expertise in
performance optimization

‣ Founder of
Whistler AB
‣ 10+ years in IT
‣ Primary expertise in missioncritical business applications

WHO ARE THOSE GUYS?

Haim Yadid
JAVA EE IN THE MULTIPROCESSOR ERA
OPTIMISM

Moore’s Law:
The amount of transistors
appx. doubles every second
year
JAVA EE IN THE FUTURE

That’s why Multi core
hardware will become
mainstream for JEE servers
18"
16"
14"
12"
10"

CPUs/server"

8"

CPUs/phone"

6"

CPUs/notebook"

4"
2"
0"
2006"

2008"

2010"

2012"

IS MULTICORE NEW TO JAVA EE?

Budget machines
A FRIENDLY ADVICE

Don’t do it yourself !!
There is an App Server for that
TOOLS OF TRADE

‣ ”Local" and cluster-wide load balancing	
‣ Message driven beans for parallelization / async tasks	
‣ Asynchronous annotations	
‣ Automatic and bean managed concurrency 	
‣ Resource management
6 REAL LIFE EXAMPLES
SYNCHRONIZATION IN EJB
You found yourself in need of sharing some data between calls so you
‣ Create a static constant pointing to a List (or perhaps your own
singleton)
‣ Add a synchronization block for your constant
‣ You operate on your instance inside the synchronize-block

SYNCHRONIZATION IN ENTERPRISE BEANS

Use Case
@Stateless
public class SharedStateEJB {
private static final List usedNumbers = new ArrayList();
public double fetchUnusedRandomNumber() {
double number = 0d;
synchronized (usedNumbers) {
while (true) {
number = Math.random();
if (!usedNumbers.contains(number)) {
usedNumbers.add(number);
break;
}
}
}
return number;
}
}

SYNCHRONIZATION IN ENTERPRISE BEANS

Returning unused random numbers
Sharing state like this will not work, because …
‣ Static constants are not shared among class loaders
‣ A lock will not is not propagated across machines

SYNCHRONIZATION IN ENTERPRISE BEANS

Problems
SYNCHRONIZATION IN ENTERPRISE BEANS

What about Java EE Singleton?
@Singleton
public class UsedNumbersBean {
private final List usedNumbers = new ArrayList();
@Lock(READ)
public boolean numberExists(double num) {
return usedNumbers.contains(num);
}
@Lock(WRITE)
public void addNumber(double num) {
usedNumbers.add(num);
}
}

SYNCHRONIZATION IN ENTERPRISE BEANS

@Singleton
“Backup” solutions
‣ Use the database and use locking => Potentially slow
‣ Use a cluster-aware cache (i.e. EHCache or JBoss Cache)
‣  Read the chapters on clusters and consistency!
‣ Terracotta
“Creative” solutions
‣ Use a single EJB
‣ Use H/A Singleton (available on JBoss)
‣ Wait for the future…

SYNCHRONIZATION IN ENTERPRISE BEANS

Suggestions
ASYNCHRONICITY THROUGH THREADS
•  You processed an order
•  You ask the bank for settlement confirmation
•  You can present the customer with a result without waiting for the
bank

ASYNCHRONICITY THROUGH THREADS

Use Case
@Stateless
public class OrderHandlingBean {
public String process(final Order order) {
String orderId = ...//save order to database and get id
final Thread t = new Thread() {
@Override public void run() {
// submit amount to bank
}
};
t.start(); // start “background” process
return orderId;
}
}

ASYNCHRONICITY THROUGH THREADS

Creating a thread for async tasks
‣ Enough stuck Threads will eventually make your server go OOM.
‣ Difficult to get transaction management right.
‣  Some servers will tell you it can’t check the status, some don’t.
‣  Failed tasks in the thread need difficult manual rollback.
‣ Threads do not scale out
‣  Can’t be load-balanced to other machines.
‣  Server’s automatic resource management doesn’t cover your own
threads.
‣ Debugging and monitoring isn’t the joy it used to be.

ASYNCHRONICITY THROUGH THREADS

Problems
1.8
1.6

Response Time

1.4
1.2
1

java.lang.OutOfMemoryError: unable to create
new native thread
Async

0.8

Sync

0.6
0.4
0.2
0
1h

4h

7h

10h
13h
Runtime

16h

19h

ASYNCHRONICITY THROUGH THREADS

Thread bugs gone wild
‣ Until Java EE 6 Message Driven Beans are used for asynchronous
tasks.
‣ And if you are lucky enough to use a Java EE 6 container, you can
use the new @Asynchronous.

ASYNCHRONICITY THROUGH THREADS

Best Practice Alternatives
@Stateless(name = ”QueueingEJB")
public class QueueingBean {
@Resource private Queue q;
@Resource private ConnectionFactory cf;
public String process(final Order order) {
// ... saving the Order to the database and fetching id
Connection cn = connectionFactory.createConnection();
Session s = cn.createSession(true, AUTO_ACKNOWLEDGE);
MessageProducer producer = s.createProducer(queue);
Message msg = s.createTextMessage(payment);
producer.send(msg);
return orderId;
}
}

Don’t forget clean-up!
We just want to
conserve screen estate!

ASYNCHRONICITY THROUGH THREADS

Using Queues
@MessageDriven(name = “PayEJB”,
activationProperties = {
/* activation properties for your server */
})
public class PayBean implements MessageListener {
public void onMessage(Message m) {
// Calling bank...
}
}

ASYNCHRONICITY THROUGH THREADS

Using Queues
@Stateless(name = ”PayEJB")
public class PayBean{
@Asynchronous
public void callBank(final String payment) {
// Hello, ... Bank!
}
}

ASYNCHRONICITY THROUGH THREADS

Using @Asynchronous
@Stateless(name = ”AsyncCallerEJB")
public class AsyncCallerBean {
@EJB private PayBean payBean;
public String process(final Order order) {
// ... saving the Order to the database and fetching id
payBean.callBank(payment);
return orderId; // <- Returns + transaction OK
}
}

That’s All!!!

ASYNCHRONICITY THROUGH THREADS

Using @Asynchronous
We mentioned transactions…
‣ True, our examples won’t use the same Transaction, but…
‣  @Asynchronous will by spec create a Transaction
(REQUIRES_NEW)
‣  MDBs will also create a transaction

ASYNCHRONICITY THROUGH THREADS

A note for the observant
PARALLELISM WITH THREAD POOLS
Your back-office staff fires off a bunch of invoices and you want the
total as fast as possible, so you…
‣ Create a thread-pool
‣ Push all invoices for calculation to the thread-pool
‣ Wait for the answer and return it

PARALLELISM WITH THREADPOOLS

Use Case
private static class OrderCallable implements Callable<Double> {
private final Order order;
public OrderCallable(Order order) {
this.order = order;
}
@Override
public Double call() throws Exception {
// return the total based on the order that’s been
// provided.
}
}

PARALLELISM WITH THREADPOOLS

Parallelizing with a ThreadPool (our Callable)
public double processOrders(List<Order> orders) {
ExecutorService executorService =
Executors.newFixedThreadPool(10);
List<Future<Double>> futures = new ArrayList<>();
for (Order order : orders) {
OrderCallable callable = new OrderCallable (order);
callables.add(callable);
futures.add(executorService.invoke (callable));
}
double totalValue = 0;
try {
for (Future<Double> future : futures) {
totalValue += future.get(10, SECONDS);
}
} catch (TimeoutException e) {
return -1;
}
return totalValue;
}

PARALLELISM WITH THREADPOOLS

Parallelizing with a ThreadPool (using the Callable in an ExecutorService)
Essentially we got the same problems as previously, but…
‣ Potential for much larger thread leaks
‣ Still not covered by transaction
‣ Executors, just like Threads, won’t run tasks on other machines.
‣ There is nothing H/A about this.
‣  On crash, part or all of the workload is gone.
‣  Can’t be resumed on server restart, it’s just gone…

PARALLELISM WITH THREADPOOLS

Problems
‣ Up to and including Java EE 5 you can use MDBs
‣  Queues can be clustered, so other servers can take some of the
load.
‣ @Asynchronous-annotated method returning Future

PARALLELISM WITH THREADPOOLS

Pure Java EE alternatives
Using @Asynchronous (invokee)
@Stateless
@Asynchronous
public class ProcessBean {
public Future<Double> getTotals(Order order) {
double value = // .. Calculate value;
return new AsyncResult<Double>(value);
}
}
@Stateless public class OrderBean {
@EJB private ProcessBean processBean;
public double parallelizeCalculationAsync(List<Order> orders) {
List<Future<Double>> futures = new ArrayList<>();
for (Order order : orders) {
futures.add(processBean.getTotals(order));
}
double totalValue = 0;
try {
for (Future<Double> future : futures) {
totalValue += future.get(10, SECONDS);
}
} catch (Exception e) {
// ignore
}
return totalValue;
}
}

PARALLELISM WITH THREADPOOLS

Using @Asynchronous (invoker)
@Stateless public class OrderBean {
@Resource(mappedName = “ConnectionFactory”) private ConnectionFactory cf;
@Resource(mappedName = “RequestQ”)
private Destination sendQueue;
@Resource(mappedName = “ResponseQ”)
private Destination responseQueue;
@TransactionAttribute(NOT_SUPPORTED) // or UserTransaction
public double handleOrders(List<Order> orders) {
try {
// …create a producer
for (Order o : orders) {
ObjectMessage outgoing = s.createObjectMessage();
outgoing.setObject(o);
outgoing.setLongProperty(“RequestID”, orders.hashCode())
mp.send(outgoing);
}
cn.start(); // must be started, otherwise we can't receive
MessageConsumer mc = s.createConsumer(responseQueue,
"JMSCorrelationID = '" + orders.hashCode() + "'");
double totalValue = 0;
for (int i = 0; i < orders.length(); i++)
totalValue += mc.receive(10, SECONDS).getDoubleProperty(“OrderValue”);
return totalValue;
} catch (JMSException e) {
throw new EJBException(e);
}
}
}

Send

Receive

PARALLELISM WITH THREADPOOLS

Using MDB (invoker)
@MessageDriven(mappedName = “RequestQ”)
public class ProcessOrderBean implements MessageListener {
@Resource(mappedName = “ConnectionFactory")
private ConnectionFactory cf;
@Resource(mappedName = “ResponseQ")
private Queue responseQueue;
public void onMessage(Message message) {
double orderValue = // ... Process order
try {
MessageProducer mp = // … create message producer
Message msg = s.createMessage();
msg.setJMSCorrelationID(message.getIntProperty(“RequestID”));
msg.setDoubleProperty(”OrderValue”, orderValue);
mp.send(msg);
} catch (JMSException e) {
throw new EJBException(e);
}
}
}

PARALLELISM WITH THREADPOOLS

Using MDB (invokee)
PARALLELISM WITH THREADPOOLS

A nice write up, but is it worth it?
12000
10000
8000
1 user

6000

10 users
20 users

4000
2000
0
Serial

8 parallel

PARALLELISM WITH THREADPOOLS

Response time – Compute intensive Tasks
FORK AND KNIVES… UHM… JOIN
‣ New to Java 7 java.util.concurrent
‣ Helps you write a parallel recursive algorithm
‣ Break a long task to Fine grained tasks
‣ Very efficient for relatively short tasks

FORK JOIN

Introduction
ForkJoinTask

FORK JOIN

Introduction

ForkJoinPool

Worker
Worker
Worker

Worker
class PartialTask extends RecursiveAction {
protected void compute() {
PartialTask pt1 = new PartialTask(firstHalf);
PartialTask pt2 = new PartialTask(secondHalf);
pt1.fork(); // fork
pt2.exec(); // execute in new thread
pt1.join(); // wait for completion
}
}
fjPool = new ForkJoinPool(para);
Para.invoke(task)

FORK JOIN

Example
‣ Divide n points into k clusters
‣ Based on proximity

FORK JOIN

A Benchmark K-Means Clustering Algorithm
‣ This is not a formal benchmark
‣ I tried to do my best but it is not community criticized
‣ Ran on 8 core machine (no HT)
‣ Windows OS
‣ Warm-up was taken into account J
‣ 120K points to 50 clusters

FORK JOIN

Disclaimer
FORK JOIN

Response Time – by amount of parallelism
6000"

5000"

Time%(sec)%

4000"

3000"
Time"
2000"

1000"

0"
1"

2"

3"

4"

5"
#cores%used%

6"

7"

8"
FORK JOIN

Speedup– by amount of parallelism
6"

5"

Time%(sec)%

4"

3"
Speedup"
2"

1"

0"
1"

2"

3"

4"

5"
#cores%used%

6"

7"

8"
FORK JOIN

Single Operation Throughput

Op/sec'
1"
0.8"
0.6"
Op/sec"

0.4"
0.2"
0"
1"

2"

3"

4"

5"

6"

7"

8"
‣ Does your server need to do anything else ?
‣ Selfish Task Deplete all compute resources slows other task
‣ What about throughput

FORK JOIN

FJ on a JEE Server
FORK JOIN

What About Throughput ?
Lets check !
‣ What will be better

FORK JOIN

Throughput of 8 Concurrent Users
FORK JOIN

Throughput 8 concurrent users in parallel

Op/sec'
1.8"
1.6"
1.4"
1.2"
1"
0.8"
0.6"
0.4"
0.2"
0"

Op/sec"

Serial"Algorithm"

Fork"Join"
Parallelism"1"

Fork"Join"
Parallelism"8"
FORK JOIN

Response Time

9000"
8000"
7000"
6000"
5000"
4000"
3000"
2000"
1000"
0"

TRT"of"8"Users"
TRT"of"1"User"

Serial"
Algorithm"

Fork"Join"
Fork"Join"
Parallelism"1" Parallelism"8"
‣ Use FJ for the non common case
‣ Limit the number of cores do not starve other server tasks

FORK JOIN

Conclusion
LOAD MANAGEMENT FOR BACKEND ACCESS
You have a backend machine that can only handle 20 concurrent
requests and you have a cluster of four servers, so you…
‣ Create a semaphore with five permits.
‣ Acquire lock on semaphore
‣ Call server
‣ Release lock

LOAD MANAGEMENT FOR BACKEND ACCESS

Use Case
‣ The backend server can be under-utilized across the cluster.
‣  First server could be full of locks while second is free.
‣ One server can stall unnecessarily long time.
‣ Recompile necessary if some parameter changes.

LOAD MANAGEMENT FOR BACKEND ACCESS

Problems With This Approach
Using the Request-Reply Pattern (EIP), using:
‣ Clustered queues (request + response)
‣ A caller (stateless session bean)
‣ A backend invoker bean (message-driven bean)
‣ Configuration to limit in-process messages
For the advanced:
‣ Write a resource adapter (JCA)
‣  Support load balancing
‣  Support cluster

LOAD MANAGEMENT FOR BACKEND ACCESS

A Better Approach
@Stateless public class DispatcherBean {
@Resource(mappedName = “ConnectionFactory”) private ConnectionFactory cf;
@Resource(mappedName = “RequestQ”)
private Destination sendQueue;
@Resource(mappedName = “ResponseQ”)
private Destination responseQueue;
@TransactionAttribute(NOT_SUPPORTED) // Alternatively UserTransaction
public double checkStockRate(String stockName) {
try {
//… create producer
Message outgoing = s.createMessage();
outgoing.setStringProperty(”StockName", stockName);
mp.send(outgoing);

Send

String correlationId = outgoing.getJMSMessageID();
cn.start(); // must be started, otherwise we can't receive
MessageConsumer mc = s.createConsumer(responseQueue,
"JMSCorrelationID = '" + correlationId + "'");
Message incoming = mc.receive(10000L); // wait no more than 10 seconds
if (incoming != null) {
return incoming.getDoubleProperty(”StockPrice");
} else {
return Double.MIN_VALUE;
}
} catch (JMSException e) {
throw new EJBException(e);
}
}
}

Receive

LOAD MANAGEMENT FOR BACKEND ACCESS

Request-Reply Pattern using clustered queues (Caller SLSB)
@MessageDriven(mappedName = “RequestQ”)
public class BackendInvokerBean implements MessageListener {
@Resource(mappedName = “ConnectionFactory")
private ConnectionFactory cf;
@Resource(mappedName = “ResponseQ")
private Queue responseQueue;
public void onMessage(Message message) {
double stockPrice = // ... Fetch from backend service
try {
// … create producer
Message msg = s.createMessage();
msg.setJMSCorrelationID(message.getJMSMessageID());
msg.setDoubleProperty(”StockPrice”, stockPrice);
mp.send(msg);
} catch (JMSException e) {
throw new EJBException(e);
}
}
}

LOAD MANAGEMENT FOR BACKEND ACCESS

Request-Reply Pattern using clustered queues (Invoker MDB)
Vendor-specific, but in general:
‣ You may set an upper limit on consumers
‣  Glassfish has maxNumActiveConsumers
‣ You may set an upper limit of MDBs in Pool
‣  Works on all servers regardless of vendor (i.e. set max-poolsize to 5 in glassfish-ejb-jar.xml)

LOAD MANAGEMENT FOR BACKEND ACCESS

Configuration for in-process limitation
LOAD MANAGEMENT FOR BACKEND ACCESS

Isn’t MDB horribly slow?
12
10
8
1 user

6

5 users
10 users

4
2
0
Direct

MDB

LOAD MANAGEMENT FOR BACKEND ACCESS

Response time (in milliseconds)
INTERFERING WITH BEAN POOL
You occasionally suffer from resource depletion so to protect your
server you:
‣ Create an EJB Interceptor that
‣  checks current beans in use (i.e. through counter or MBeans)
‣  throws an exception at chosen maximum size.
‣  Or wait until level go down
‣ Assign it to your EJB.

INTERFERING WITH BEAN POOL

Use Case
‣ Is there always equal load distribution across all tasks?
‣ Intelligent load balancers may continue to shoot at the wrong target
‣  It’s just an exception… not an overload
‣ DeadLock

INTERFERING WITH BEAN POOL

Problems
Leave pool management to the server, pool sizes:
‣ Can be tuned on a global level
‣  Right strategy (infinite thread pools, incremental, fixed)
‣  Global default for min/max/timeout
‣ Can be set for each EJB
‣  XML
‣  Annotations (i.e. JBoss)

INTERFERING WITH BEAN POOL

Better approach
It can be configured through the GUI…(Glassfish example)

INTERFERING WITH BEAN POOL

Leave Management to the app server
<glassfish-ejb-jar>
<enterprise-beans>
<ejb>
<ejb-name>AnEJB</ejb-name>
<bean-pool>
<steady-pool-size>10</steady-pool-size>
<resize-quantity>10</resize-quantity>
<max-pool-size>100</max-pool-size>
<pool-idle-timeout-in-seconds>
60
</pool-idle-timeout-in-seconds>
</bean-pool>
</ejb>
</enterprise-beans>
</glassfish-ejb-jar>

INTERFERING WITH BEAN POOL

Through Config Files
CONCLUSION
CONCLUSION

‣ Most mistakes stem from misunderstanding the app server, try to
understand your app server’s OOTB-capabilities…
‣ …and the Java EE specification.
‣ If you have a valid case for your own concurrency-related code,
make sure it plays well with the container.
‣ Your app server doesn’t always know best, but it often does. And if
not, you can often help it understand!
‣ Do not expect your environment to always look the same, it changes
quicker than you might think.
QUESTIONS?
haim.yadid@gmail.com

Daniel Pfeifer
danpfe@gmail.com

CONTACT INFO

Haim Yadid

Mais conteúdo relacionado

Mais procurados

Atlanta JUG - Integrating Spring Batch and Spring Integration
Atlanta JUG - Integrating Spring Batch and Spring IntegrationAtlanta JUG - Integrating Spring Batch and Spring Integration
Atlanta JUG - Integrating Spring Batch and Spring IntegrationGunnar Hillert
 
Apache Aries Overview
Apache Aries   OverviewApache Aries   Overview
Apache Aries OverviewIan Robinson
 
Java MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & OptimizationJava MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & OptimizationKenny Gryp
 
Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Ryan Cuprak
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisFastly
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akkanartamonov
 
Scaling Your Cache
Scaling Your CacheScaling Your Cache
Scaling Your CacheAlex Miller
 
Apache Commons Pool and DBCP - Version 2 Update
Apache Commons Pool and DBCP - Version 2 UpdateApache Commons Pool and DBCP - Version 2 Update
Apache Commons Pool and DBCP - Version 2 UpdatePhil Steitz
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous ApplicationsJohan Edstrom
 
a Running Tour of Cloud Foundry
a Running Tour of Cloud Foundrya Running Tour of Cloud Foundry
a Running Tour of Cloud FoundryJoshua Long
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaJames Falkner
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camelkrasserm
 
Java Play Restful JPA
Java Play Restful JPAJava Play Restful JPA
Java Play Restful JPAFaren faren
 
Solving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and ScalabilitySolving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and ScalabilityZendCon
 
R2DBC Reactive Relational Database Connectivity
R2DBC Reactive Relational Database ConnectivityR2DBC Reactive Relational Database Connectivity
R2DBC Reactive Relational Database ConnectivityMaarten Smeets
 

Mais procurados (20)

JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter PilgrimJavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
JavaCro'14 - Scala and Java EE 7 Development Experiences – Peter Pilgrim
 
Atlanta JUG - Integrating Spring Batch and Spring Integration
Atlanta JUG - Integrating Spring Batch and Spring IntegrationAtlanta JUG - Integrating Spring Batch and Spring Integration
Atlanta JUG - Integrating Spring Batch and Spring Integration
 
Apache Aries Overview
Apache Aries   OverviewApache Aries   Overview
Apache Aries Overview
 
Connection Pooling
Connection PoolingConnection Pooling
Connection Pooling
 
Woa. Reloaded
Woa. ReloadedWoa. Reloaded
Woa. Reloaded
 
Java MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & OptimizationJava MySQL Connector & Connection Pool Features & Optimization
Java MySQL Connector & Connection Pool Features & Optimization
 
Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)Batching and Java EE (jdk.io)
Batching and Java EE (jdk.io)
 
Beyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic AnalysisBeyond Breakpoints: A Tour of Dynamic Analysis
Beyond Breakpoints: A Tour of Dynamic Analysis
 
Ehcache 3 @ BruJUG
Ehcache 3 @ BruJUGEhcache 3 @ BruJUG
Ehcache 3 @ BruJUG
 
Above the clouds: introducing Akka
Above the clouds: introducing AkkaAbove the clouds: introducing Akka
Above the clouds: introducing Akka
 
Scaling Your Cache
Scaling Your CacheScaling Your Cache
Scaling Your Cache
 
Apache Commons Pool and DBCP - Version 2 Update
Apache Commons Pool and DBCP - Version 2 UpdateApache Commons Pool and DBCP - Version 2 Update
Apache Commons Pool and DBCP - Version 2 Update
 
Building Asynchronous Applications
Building Asynchronous ApplicationsBuilding Asynchronous Applications
Building Asynchronous Applications
 
a Running Tour of Cloud Foundry
a Running Tour of Cloud Foundrya Running Tour of Cloud Foundry
a Running Tour of Cloud Foundry
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and Java
 
System Integration with Akka and Apache Camel
System Integration with Akka and Apache CamelSystem Integration with Akka and Apache Camel
System Integration with Akka and Apache Camel
 
Hibernate performance tuning
Hibernate performance tuningHibernate performance tuning
Hibernate performance tuning
 
Java Play Restful JPA
Java Play Restful JPAJava Play Restful JPA
Java Play Restful JPA
 
Solving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and ScalabilitySolving the C20K problem: Raising the bar in PHP Performance and Scalability
Solving the C20K problem: Raising the bar in PHP Performance and Scalability
 
R2DBC Reactive Relational Database Connectivity
R2DBC Reactive Relational Database ConnectivityR2DBC Reactive Relational Database Connectivity
R2DBC Reactive Relational Database Connectivity
 

Semelhante a Java Enterprise Edition Concurrency Misconceptions

Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxbobmcwhirter
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA PresentationRob Tweed
 
Faster PHP apps using Queues and Workers
Faster PHP apps using Queues and WorkersFaster PHP apps using Queues and Workers
Faster PHP apps using Queues and WorkersRichard Baker
 
Asynchronous programming - .NET Way
Asynchronous programming - .NET WayAsynchronous programming - .NET Way
Asynchronous programming - .NET WayBishnu Rawal
 
More efficient, usable web
More efficient, usable webMore efficient, usable web
More efficient, usable webChris Mills
 
Client-Server-Kommunikation mit dem Command Pattern
Client-Server-Kommunikation mit dem Command PatternClient-Server-Kommunikation mit dem Command Pattern
Client-Server-Kommunikation mit dem Command Patternpgt technology scouting GmbH
 
Rails Conf Europe 2007 Notes
Rails Conf  Europe 2007  NotesRails Conf  Europe 2007  Notes
Rails Conf Europe 2007 NotesRoss Lawley
 
Adventures in Multithreaded Core Data
Adventures in Multithreaded Core DataAdventures in Multithreaded Core Data
Adventures in Multithreaded Core DataInferis
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteDr Nic Williams
 
Stress Testing at Twitter: a tale of New Year Eves
Stress Testing at Twitter: a tale of New Year EvesStress Testing at Twitter: a tale of New Year Eves
Stress Testing at Twitter: a tale of New Year EvesHerval Freire
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous JavascriptGarrett Welson
 
Creating Fault Tolerant Services on Mesos
Creating Fault Tolerant Services on MesosCreating Fault Tolerant Services on Mesos
Creating Fault Tolerant Services on MesosArangoDB Database
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With TerracottaPT.JUG
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client DevelopmentTamir Khason
 
Effective Test Driven Database Development
Effective Test Driven Database DevelopmentEffective Test Driven Database Development
Effective Test Driven Database Developmentelliando dias
 
Planning to Fail #phpne13
Planning to Fail #phpne13Planning to Fail #phpne13
Planning to Fail #phpne13Dave Gardner
 
Node, can you even in CPU intensive operations?
Node, can you even in CPU intensive operations?Node, can you even in CPU intensive operations?
Node, can you even in CPU intensive operations?The Software House
 
Intro to Cascading
Intro to CascadingIntro to Cascading
Intro to CascadingBen Speakmon
 

Semelhante a Java Enterprise Edition Concurrency Misconceptions (20)

Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
Node.js: CAMTA Presentation
Node.js: CAMTA PresentationNode.js: CAMTA Presentation
Node.js: CAMTA Presentation
 
Faster PHP apps using Queues and Workers
Faster PHP apps using Queues and WorkersFaster PHP apps using Queues and Workers
Faster PHP apps using Queues and Workers
 
Asynchronous programming - .NET Way
Asynchronous programming - .NET WayAsynchronous programming - .NET Way
Asynchronous programming - .NET Way
 
More efficient, usable web
More efficient, usable webMore efficient, usable web
More efficient, usable web
 
Taskflow
TaskflowTaskflow
Taskflow
 
Client-Server-Kommunikation mit dem Command Pattern
Client-Server-Kommunikation mit dem Command PatternClient-Server-Kommunikation mit dem Command Pattern
Client-Server-Kommunikation mit dem Command Pattern
 
Rails Conf Europe 2007 Notes
Rails Conf  Europe 2007  NotesRails Conf  Europe 2007  Notes
Rails Conf Europe 2007 Notes
 
Adventures in Multithreaded Core Data
Adventures in Multithreaded Core DataAdventures in Multithreaded Core Data
Adventures in Multithreaded Core Data
 
RubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - KeynoteRubyEnRails2007 - Dr Nic Williams - Keynote
RubyEnRails2007 - Dr Nic Williams - Keynote
 
Stress Testing at Twitter: a tale of New Year Eves
Stress Testing at Twitter: a tale of New Year EvesStress Testing at Twitter: a tale of New Year Eves
Stress Testing at Twitter: a tale of New Year Eves
 
Intro to Asynchronous Javascript
Intro to Asynchronous JavascriptIntro to Asynchronous Javascript
Intro to Asynchronous Javascript
 
Continuuity Weave
Continuuity WeaveContinuuity Weave
Continuuity Weave
 
Creating Fault Tolerant Services on Mesos
Creating Fault Tolerant Services on MesosCreating Fault Tolerant Services on Mesos
Creating Fault Tolerant Services on Mesos
 
Lightweight Grids With Terracotta
Lightweight Grids With TerracottaLightweight Grids With Terracotta
Lightweight Grids With Terracotta
 
Smart Client Development
Smart Client DevelopmentSmart Client Development
Smart Client Development
 
Effective Test Driven Database Development
Effective Test Driven Database DevelopmentEffective Test Driven Database Development
Effective Test Driven Database Development
 
Planning to Fail #phpne13
Planning to Fail #phpne13Planning to Fail #phpne13
Planning to Fail #phpne13
 
Node, can you even in CPU intensive operations?
Node, can you even in CPU intensive operations?Node, can you even in CPU intensive operations?
Node, can you even in CPU intensive operations?
 
Intro to Cascading
Intro to CascadingIntro to Cascading
Intro to Cascading
 

Mais de Haim Yadid

Loom me up Scotty! Project Loom - What's in it for Me?
Loom me up Scotty!  Project Loom - What's in it for Me?Loom me up Scotty!  Project Loom - What's in it for Me?
Loom me up Scotty! Project Loom - What's in it for Me?Haim Yadid
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a FoeHaim Yadid
 
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyKotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyHaim Yadid
 
“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage CollectionHaim Yadid
 
Java Memory Structure
Java Memory Structure Java Memory Structure
Java Memory Structure Haim Yadid
 
Basic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With JmxBasic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With JmxHaim Yadid
 
The Freelancer Journey
The Freelancer JourneyThe Freelancer Journey
The Freelancer JourneyHaim Yadid
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with KotlinHaim Yadid
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyHaim Yadid
 
Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage CollectionHaim Yadid
 
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...Haim Yadid
 
mjprof: Monadic approach for JVM profiling
mjprof: Monadic approach for JVM profilingmjprof: Monadic approach for JVM profiling
mjprof: Monadic approach for JVM profilingHaim Yadid
 
Java 8 Launch - MetaSpaces
Java 8 Launch - MetaSpacesJava 8 Launch - MetaSpaces
Java 8 Launch - MetaSpacesHaim Yadid
 
Java 8 - Stamped Lock
Java 8 - Stamped LockJava 8 - Stamped Lock
Java 8 - Stamped LockHaim Yadid
 
The Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesThe Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesHaim Yadid
 
Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Haim Yadid
 
A short Intro. to Java Mission Control
A short Intro. to Java Mission ControlA short Intro. to Java Mission Control
A short Intro. to Java Mission ControlHaim Yadid
 
Tales About Scala Performance
Tales About Scala PerformanceTales About Scala Performance
Tales About Scala PerformanceHaim Yadid
 
Israeli JUG - IL JUG presentation
Israeli JUG -  IL JUG presentation Israeli JUG -  IL JUG presentation
Israeli JUG - IL JUG presentation Haim Yadid
 

Mais de Haim Yadid (19)

Loom me up Scotty! Project Loom - What's in it for Me?
Loom me up Scotty!  Project Loom - What's in it for Me?Loom me up Scotty!  Project Loom - What's in it for Me?
Loom me up Scotty! Project Loom - What's in it for Me?
 
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
“Show Me the Garbage!”, Garbage Collection a Friend or a Foe
 
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the UglyKotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
Kotlin Backend Development 6 Yrs Recap. The Good, the Bad and the Ugly
 
“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection
 
Java Memory Structure
Java Memory Structure Java Memory Structure
Java Memory Structure
 
Basic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With JmxBasic JVM Troubleshooting With Jmx
Basic JVM Troubleshooting With Jmx
 
The Freelancer Journey
The Freelancer JourneyThe Freelancer Journey
The Freelancer Journey
 
Building microservices with Kotlin
Building microservices with KotlinBuilding microservices with Kotlin
Building microservices with Kotlin
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, Seriously
 
Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage Collection
 
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
JVM Garbage Collection logs, you do not want to ignore them! - Reversim Summi...
 
mjprof: Monadic approach for JVM profiling
mjprof: Monadic approach for JVM profilingmjprof: Monadic approach for JVM profiling
mjprof: Monadic approach for JVM profiling
 
Java 8 Launch - MetaSpaces
Java 8 Launch - MetaSpacesJava 8 Launch - MetaSpaces
Java 8 Launch - MetaSpaces
 
Java 8 - Stamped Lock
Java 8 - Stamped LockJava 8 - Stamped Lock
Java 8 - Stamped Lock
 
The Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFuturesThe Future of Futures - A Talk About Java 8 CompletableFutures
The Future of Futures - A Talk About Java 8 CompletableFutures
 
Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014Concurrency and Multithreading Demistified - Reversim Summit 2014
Concurrency and Multithreading Demistified - Reversim Summit 2014
 
A short Intro. to Java Mission Control
A short Intro. to Java Mission ControlA short Intro. to Java Mission Control
A short Intro. to Java Mission Control
 
Tales About Scala Performance
Tales About Scala PerformanceTales About Scala Performance
Tales About Scala Performance
 
Israeli JUG - IL JUG presentation
Israeli JUG -  IL JUG presentation Israeli JUG -  IL JUG presentation
Israeli JUG - IL JUG presentation
 

Último

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Último (20)

TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Java Enterprise Edition Concurrency Misconceptions

  • 1. JAVA EE CONCURRENCY MISCONCEPTIONS Haim Yadid, Performize-IT Ltd. Daniel Pfeifer, Whistler AB
  • 2. Daniel Pfeifer ‣ Founder of Performize-IT Ltd. ‣ 18+ years in technology ‣ Primary expertise in performance optimization ‣ Founder of Whistler AB ‣ 10+ years in IT ‣ Primary expertise in missioncritical business applications WHO ARE THOSE GUYS? Haim Yadid
  • 3. JAVA EE IN THE MULTIPROCESSOR ERA
  • 4. OPTIMISM Moore’s Law: The amount of transistors appx. doubles every second year
  • 5. JAVA EE IN THE FUTURE That’s why Multi core hardware will become mainstream for JEE servers
  • 7. A FRIENDLY ADVICE Don’t do it yourself !!
  • 8. There is an App Server for that
  • 9. TOOLS OF TRADE ‣ ”Local" and cluster-wide load balancing ‣ Message driven beans for parallelization / async tasks ‣ Asynchronous annotations ‣ Automatic and bean managed concurrency ‣ Resource management
  • 10. 6 REAL LIFE EXAMPLES
  • 12. You found yourself in need of sharing some data between calls so you ‣ Create a static constant pointing to a List (or perhaps your own singleton) ‣ Add a synchronization block for your constant ‣ You operate on your instance inside the synchronize-block SYNCHRONIZATION IN ENTERPRISE BEANS Use Case
  • 13. @Stateless public class SharedStateEJB { private static final List usedNumbers = new ArrayList(); public double fetchUnusedRandomNumber() { double number = 0d; synchronized (usedNumbers) { while (true) { number = Math.random(); if (!usedNumbers.contains(number)) { usedNumbers.add(number); break; } } } return number; } } SYNCHRONIZATION IN ENTERPRISE BEANS Returning unused random numbers
  • 14. Sharing state like this will not work, because … ‣ Static constants are not shared among class loaders ‣ A lock will not is not propagated across machines SYNCHRONIZATION IN ENTERPRISE BEANS Problems
  • 15. SYNCHRONIZATION IN ENTERPRISE BEANS What about Java EE Singleton?
  • 16. @Singleton public class UsedNumbersBean { private final List usedNumbers = new ArrayList(); @Lock(READ) public boolean numberExists(double num) { return usedNumbers.contains(num); } @Lock(WRITE) public void addNumber(double num) { usedNumbers.add(num); } } SYNCHRONIZATION IN ENTERPRISE BEANS @Singleton
  • 17. “Backup” solutions ‣ Use the database and use locking => Potentially slow ‣ Use a cluster-aware cache (i.e. EHCache or JBoss Cache) ‣  Read the chapters on clusters and consistency! ‣ Terracotta “Creative” solutions ‣ Use a single EJB ‣ Use H/A Singleton (available on JBoss) ‣ Wait for the future… SYNCHRONIZATION IN ENTERPRISE BEANS Suggestions
  • 19. •  You processed an order •  You ask the bank for settlement confirmation •  You can present the customer with a result without waiting for the bank ASYNCHRONICITY THROUGH THREADS Use Case
  • 20. @Stateless public class OrderHandlingBean { public String process(final Order order) { String orderId = ...//save order to database and get id final Thread t = new Thread() { @Override public void run() { // submit amount to bank } }; t.start(); // start “background” process return orderId; } } ASYNCHRONICITY THROUGH THREADS Creating a thread for async tasks
  • 21. ‣ Enough stuck Threads will eventually make your server go OOM. ‣ Difficult to get transaction management right. ‣  Some servers will tell you it can’t check the status, some don’t. ‣  Failed tasks in the thread need difficult manual rollback. ‣ Threads do not scale out ‣  Can’t be load-balanced to other machines. ‣  Server’s automatic resource management doesn’t cover your own threads. ‣ Debugging and monitoring isn’t the joy it used to be. ASYNCHRONICITY THROUGH THREADS Problems
  • 22. 1.8 1.6 Response Time 1.4 1.2 1 java.lang.OutOfMemoryError: unable to create new native thread Async 0.8 Sync 0.6 0.4 0.2 0 1h 4h 7h 10h 13h Runtime 16h 19h ASYNCHRONICITY THROUGH THREADS Thread bugs gone wild
  • 23. ‣ Until Java EE 6 Message Driven Beans are used for asynchronous tasks. ‣ And if you are lucky enough to use a Java EE 6 container, you can use the new @Asynchronous. ASYNCHRONICITY THROUGH THREADS Best Practice Alternatives
  • 24. @Stateless(name = ”QueueingEJB") public class QueueingBean { @Resource private Queue q; @Resource private ConnectionFactory cf; public String process(final Order order) { // ... saving the Order to the database and fetching id Connection cn = connectionFactory.createConnection(); Session s = cn.createSession(true, AUTO_ACKNOWLEDGE); MessageProducer producer = s.createProducer(queue); Message msg = s.createTextMessage(payment); producer.send(msg); return orderId; } } Don’t forget clean-up! We just want to conserve screen estate! ASYNCHRONICITY THROUGH THREADS Using Queues
  • 25. @MessageDriven(name = “PayEJB”, activationProperties = { /* activation properties for your server */ }) public class PayBean implements MessageListener { public void onMessage(Message m) { // Calling bank... } } ASYNCHRONICITY THROUGH THREADS Using Queues
  • 26. @Stateless(name = ”PayEJB") public class PayBean{ @Asynchronous public void callBank(final String payment) { // Hello, ... Bank! } } ASYNCHRONICITY THROUGH THREADS Using @Asynchronous
  • 27. @Stateless(name = ”AsyncCallerEJB") public class AsyncCallerBean { @EJB private PayBean payBean; public String process(final Order order) { // ... saving the Order to the database and fetching id payBean.callBank(payment); return orderId; // <- Returns + transaction OK } } That’s All!!! ASYNCHRONICITY THROUGH THREADS Using @Asynchronous
  • 28. We mentioned transactions… ‣ True, our examples won’t use the same Transaction, but… ‣  @Asynchronous will by spec create a Transaction (REQUIRES_NEW) ‣  MDBs will also create a transaction ASYNCHRONICITY THROUGH THREADS A note for the observant
  • 30. Your back-office staff fires off a bunch of invoices and you want the total as fast as possible, so you… ‣ Create a thread-pool ‣ Push all invoices for calculation to the thread-pool ‣ Wait for the answer and return it PARALLELISM WITH THREADPOOLS Use Case
  • 31. private static class OrderCallable implements Callable<Double> { private final Order order; public OrderCallable(Order order) { this.order = order; } @Override public Double call() throws Exception { // return the total based on the order that’s been // provided. } } PARALLELISM WITH THREADPOOLS Parallelizing with a ThreadPool (our Callable)
  • 32. public double processOrders(List<Order> orders) { ExecutorService executorService = Executors.newFixedThreadPool(10); List<Future<Double>> futures = new ArrayList<>(); for (Order order : orders) { OrderCallable callable = new OrderCallable (order); callables.add(callable); futures.add(executorService.invoke (callable)); } double totalValue = 0; try { for (Future<Double> future : futures) { totalValue += future.get(10, SECONDS); } } catch (TimeoutException e) { return -1; } return totalValue; } PARALLELISM WITH THREADPOOLS Parallelizing with a ThreadPool (using the Callable in an ExecutorService)
  • 33. Essentially we got the same problems as previously, but… ‣ Potential for much larger thread leaks ‣ Still not covered by transaction ‣ Executors, just like Threads, won’t run tasks on other machines. ‣ There is nothing H/A about this. ‣  On crash, part or all of the workload is gone. ‣  Can’t be resumed on server restart, it’s just gone… PARALLELISM WITH THREADPOOLS Problems
  • 34. ‣ Up to and including Java EE 5 you can use MDBs ‣  Queues can be clustered, so other servers can take some of the load. ‣ @Asynchronous-annotated method returning Future PARALLELISM WITH THREADPOOLS Pure Java EE alternatives
  • 35. Using @Asynchronous (invokee) @Stateless @Asynchronous public class ProcessBean { public Future<Double> getTotals(Order order) { double value = // .. Calculate value; return new AsyncResult<Double>(value); } }
  • 36. @Stateless public class OrderBean { @EJB private ProcessBean processBean; public double parallelizeCalculationAsync(List<Order> orders) { List<Future<Double>> futures = new ArrayList<>(); for (Order order : orders) { futures.add(processBean.getTotals(order)); } double totalValue = 0; try { for (Future<Double> future : futures) { totalValue += future.get(10, SECONDS); } } catch (Exception e) { // ignore } return totalValue; } } PARALLELISM WITH THREADPOOLS Using @Asynchronous (invoker)
  • 37. @Stateless public class OrderBean { @Resource(mappedName = “ConnectionFactory”) private ConnectionFactory cf; @Resource(mappedName = “RequestQ”) private Destination sendQueue; @Resource(mappedName = “ResponseQ”) private Destination responseQueue; @TransactionAttribute(NOT_SUPPORTED) // or UserTransaction public double handleOrders(List<Order> orders) { try { // …create a producer for (Order o : orders) { ObjectMessage outgoing = s.createObjectMessage(); outgoing.setObject(o); outgoing.setLongProperty(“RequestID”, orders.hashCode()) mp.send(outgoing); } cn.start(); // must be started, otherwise we can't receive MessageConsumer mc = s.createConsumer(responseQueue, "JMSCorrelationID = '" + orders.hashCode() + "'"); double totalValue = 0; for (int i = 0; i < orders.length(); i++) totalValue += mc.receive(10, SECONDS).getDoubleProperty(“OrderValue”); return totalValue; } catch (JMSException e) { throw new EJBException(e); } } } Send Receive PARALLELISM WITH THREADPOOLS Using MDB (invoker)
  • 38. @MessageDriven(mappedName = “RequestQ”) public class ProcessOrderBean implements MessageListener { @Resource(mappedName = “ConnectionFactory") private ConnectionFactory cf; @Resource(mappedName = “ResponseQ") private Queue responseQueue; public void onMessage(Message message) { double orderValue = // ... Process order try { MessageProducer mp = // … create message producer Message msg = s.createMessage(); msg.setJMSCorrelationID(message.getIntProperty(“RequestID”)); msg.setDoubleProperty(”OrderValue”, orderValue); mp.send(msg); } catch (JMSException e) { throw new EJBException(e); } } } PARALLELISM WITH THREADPOOLS Using MDB (invokee)
  • 39. PARALLELISM WITH THREADPOOLS A nice write up, but is it worth it?
  • 40. 12000 10000 8000 1 user 6000 10 users 20 users 4000 2000 0 Serial 8 parallel PARALLELISM WITH THREADPOOLS Response time – Compute intensive Tasks
  • 41. FORK AND KNIVES… UHM… JOIN
  • 42. ‣ New to Java 7 java.util.concurrent ‣ Helps you write a parallel recursive algorithm ‣ Break a long task to Fine grained tasks ‣ Very efficient for relatively short tasks FORK JOIN Introduction
  • 44. class PartialTask extends RecursiveAction { protected void compute() { PartialTask pt1 = new PartialTask(firstHalf); PartialTask pt2 = new PartialTask(secondHalf); pt1.fork(); // fork pt2.exec(); // execute in new thread pt1.join(); // wait for completion } } fjPool = new ForkJoinPool(para); Para.invoke(task) FORK JOIN Example
  • 45. ‣ Divide n points into k clusters ‣ Based on proximity FORK JOIN A Benchmark K-Means Clustering Algorithm
  • 46. ‣ This is not a formal benchmark ‣ I tried to do my best but it is not community criticized ‣ Ran on 8 core machine (no HT) ‣ Windows OS ‣ Warm-up was taken into account J ‣ 120K points to 50 clusters FORK JOIN Disclaimer
  • 47. FORK JOIN Response Time – by amount of parallelism 6000" 5000" Time%(sec)% 4000" 3000" Time" 2000" 1000" 0" 1" 2" 3" 4" 5" #cores%used% 6" 7" 8"
  • 48. FORK JOIN Speedup– by amount of parallelism 6" 5" Time%(sec)% 4" 3" Speedup" 2" 1" 0" 1" 2" 3" 4" 5" #cores%used% 6" 7" 8"
  • 49. FORK JOIN Single Operation Throughput Op/sec' 1" 0.8" 0.6" Op/sec" 0.4" 0.2" 0" 1" 2" 3" 4" 5" 6" 7" 8"
  • 50. ‣ Does your server need to do anything else ? ‣ Selfish Task Deplete all compute resources slows other task ‣ What about throughput FORK JOIN FJ on a JEE Server
  • 51. FORK JOIN What About Throughput ? Lets check !
  • 52. ‣ What will be better FORK JOIN Throughput of 8 Concurrent Users
  • 53. FORK JOIN Throughput 8 concurrent users in parallel Op/sec' 1.8" 1.6" 1.4" 1.2" 1" 0.8" 0.6" 0.4" 0.2" 0" Op/sec" Serial"Algorithm" Fork"Join" Parallelism"1" Fork"Join" Parallelism"8"
  • 55. ‣ Use FJ for the non common case ‣ Limit the number of cores do not starve other server tasks FORK JOIN Conclusion
  • 56. LOAD MANAGEMENT FOR BACKEND ACCESS
  • 57. You have a backend machine that can only handle 20 concurrent requests and you have a cluster of four servers, so you… ‣ Create a semaphore with five permits. ‣ Acquire lock on semaphore ‣ Call server ‣ Release lock LOAD MANAGEMENT FOR BACKEND ACCESS Use Case
  • 58. ‣ The backend server can be under-utilized across the cluster. ‣  First server could be full of locks while second is free. ‣ One server can stall unnecessarily long time. ‣ Recompile necessary if some parameter changes. LOAD MANAGEMENT FOR BACKEND ACCESS Problems With This Approach
  • 59. Using the Request-Reply Pattern (EIP), using: ‣ Clustered queues (request + response) ‣ A caller (stateless session bean) ‣ A backend invoker bean (message-driven bean) ‣ Configuration to limit in-process messages For the advanced: ‣ Write a resource adapter (JCA) ‣  Support load balancing ‣  Support cluster LOAD MANAGEMENT FOR BACKEND ACCESS A Better Approach
  • 60. @Stateless public class DispatcherBean { @Resource(mappedName = “ConnectionFactory”) private ConnectionFactory cf; @Resource(mappedName = “RequestQ”) private Destination sendQueue; @Resource(mappedName = “ResponseQ”) private Destination responseQueue; @TransactionAttribute(NOT_SUPPORTED) // Alternatively UserTransaction public double checkStockRate(String stockName) { try { //… create producer Message outgoing = s.createMessage(); outgoing.setStringProperty(”StockName", stockName); mp.send(outgoing); Send String correlationId = outgoing.getJMSMessageID(); cn.start(); // must be started, otherwise we can't receive MessageConsumer mc = s.createConsumer(responseQueue, "JMSCorrelationID = '" + correlationId + "'"); Message incoming = mc.receive(10000L); // wait no more than 10 seconds if (incoming != null) { return incoming.getDoubleProperty(”StockPrice"); } else { return Double.MIN_VALUE; } } catch (JMSException e) { throw new EJBException(e); } } } Receive LOAD MANAGEMENT FOR BACKEND ACCESS Request-Reply Pattern using clustered queues (Caller SLSB)
  • 61. @MessageDriven(mappedName = “RequestQ”) public class BackendInvokerBean implements MessageListener { @Resource(mappedName = “ConnectionFactory") private ConnectionFactory cf; @Resource(mappedName = “ResponseQ") private Queue responseQueue; public void onMessage(Message message) { double stockPrice = // ... Fetch from backend service try { // … create producer Message msg = s.createMessage(); msg.setJMSCorrelationID(message.getJMSMessageID()); msg.setDoubleProperty(”StockPrice”, stockPrice); mp.send(msg); } catch (JMSException e) { throw new EJBException(e); } } } LOAD MANAGEMENT FOR BACKEND ACCESS Request-Reply Pattern using clustered queues (Invoker MDB)
  • 62. Vendor-specific, but in general: ‣ You may set an upper limit on consumers ‣  Glassfish has maxNumActiveConsumers ‣ You may set an upper limit of MDBs in Pool ‣  Works on all servers regardless of vendor (i.e. set max-poolsize to 5 in glassfish-ejb-jar.xml) LOAD MANAGEMENT FOR BACKEND ACCESS Configuration for in-process limitation
  • 63. LOAD MANAGEMENT FOR BACKEND ACCESS Isn’t MDB horribly slow?
  • 64. 12 10 8 1 user 6 5 users 10 users 4 2 0 Direct MDB LOAD MANAGEMENT FOR BACKEND ACCESS Response time (in milliseconds)
  • 66. You occasionally suffer from resource depletion so to protect your server you: ‣ Create an EJB Interceptor that ‣  checks current beans in use (i.e. through counter or MBeans) ‣  throws an exception at chosen maximum size. ‣  Or wait until level go down ‣ Assign it to your EJB. INTERFERING WITH BEAN POOL Use Case
  • 67. ‣ Is there always equal load distribution across all tasks? ‣ Intelligent load balancers may continue to shoot at the wrong target ‣  It’s just an exception… not an overload ‣ DeadLock INTERFERING WITH BEAN POOL Problems
  • 68. Leave pool management to the server, pool sizes: ‣ Can be tuned on a global level ‣  Right strategy (infinite thread pools, incremental, fixed) ‣  Global default for min/max/timeout ‣ Can be set for each EJB ‣  XML ‣  Annotations (i.e. JBoss) INTERFERING WITH BEAN POOL Better approach
  • 69. It can be configured through the GUI…(Glassfish example) INTERFERING WITH BEAN POOL Leave Management to the app server
  • 72. CONCLUSION ‣ Most mistakes stem from misunderstanding the app server, try to understand your app server’s OOTB-capabilities… ‣ …and the Java EE specification. ‣ If you have a valid case for your own concurrency-related code, make sure it plays well with the container. ‣ Your app server doesn’t always know best, but it often does. And if not, you can often help it understand! ‣ Do not expect your environment to always look the same, it changes quicker than you might think.