SlideShare ist ein Scribd-Unternehmen logo
1 von 65
Downloaden Sie, um offline zu lesen
Chicago, October 19 - 22, 2010
Concurrent Programming
and Distributed Applications
Mark Fisher, Dave Syer - SpringSource
Goal
●
Demystify concurrent and distributed programming.
●
Identify and help avoid the pitfalls
●
Show how Spring makes it easier to write multi-
threaded and multi-process applications
Agenda
• Concurrency
• Asynchronous execution
• Tasks, schedules and triggers
• Events, Messaging and intra-process communication
• Distributed systems
Concurrency
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Why?
- Performance
- Responsiveness
- Scalability
Where?
- Event-driven Architecture
- Scheduling Tasks
When threads were more esoteric,
concurrency was an "advanced" topic;
now, mainstream developers must be
aware of thread-safety issues.
--Brian Goetz
Thread Safe?
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
public class Counter {
private boolean active = false;
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
}
Thread Safe?
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
public class Counter {
private volatile int count = 0;
public int increment() {
return count++;
}
}
Thread Safe?
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
public class Service {
private volatile Resource resource;
public void process(String data) {
if (this.resource == null) {
this.resource = new Resource();
}
this.resource.process(data);
}
}
Thread Safety
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
What?
Properly managing concurrent access to mutable state.
How?
a) avoid mutability
b) don't share
c) synchronize
Immutable?
public class StringHolder {
private final int id;
private final String value;
public StringHolder(int id, String value) {
this.id = id;
this.value = value;
}
public void display() {
Sysem.out.println(id + ": " + this.value);
}
}
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Immutable?
public class StringList {
private final int id;
private final List<String> strings;
public StringList(int id, List<String> strings) {
this.id = id;
this.strings = strings;
}
public void display() {
Sysem.out.println(id + ": " + this.strings);
}
}
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Immutable?
public class MapHolder {
private final Map<Integer, StringValue> map;
public MapHolder(Map<Integer, StringValue> map) {
this.map = new HashMap<Integer, StringValue>(map);
}
public void display() {
System.out.println(this.map);
}
}
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Immutable?
private final Map<Integer, StringValue> map;
public MapHolder(Map<Integer, StringValue> map) {
this.map = new HashMap<Integer, StringValue>(map);
}
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
public static class StringValue {
private String string;
public StringValue(String string) {
this.string = string;
}
public void setString(String string) {
this.string = string;
}
}
public static class StringValue {
private String string;
public StringValue(String string) {
this.string = string;
}
public void setString(String string) {
this.string = string;
}
}
Immutable?
private final Map<Integer, StringValue> map;
public MapHolder(Map<Integer, StringValue> map) {
this.map = new HashMap<Integer, StringValue>(map);
}
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
public static class StringValue {
private final String string;
public StringValue(String string) {
this.string = string;
}
}
public static class StringValue {
private final String string;
public StringValue(String string) {
this.string = string;
}
}
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
Thread Safety: Confinement
When immutability is not an option, consider not sharing
mutable state
• Stack Confinement
– Method Parameters
– Local Variables
• Thread Confinement
– ThreadLocal
– Custom Scopes in Spring
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
Synchronization
• The 'synchronized' keyword
• Locks
• wait/notify
• Atomic variables
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
Lazy Initialization (recap)
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
public class Service {
private volatile Resource resource;
public void process(String data) {
if (this.resource == null) {
this.resource = new Resource();
}
this.resource.process(data);
}
}
Dependency Injection and Singletons
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
public class Service {
private volatile Resource resource;
public void setResource(Resources resource) {
this.resource = resource;
}
public void process(String data) {
this.resource.process(data);
}
}
Concurrency
• Background processing and performance optimization
• Java Memory Model: final, volatile, synchronized
• Locks: wait, notify, utility wrappers
• Concurrent collections, immutable wrappers
• Queue, BlockingQueue, DelayQueue
• Deadlock, livelock, starvation
• Immutability, stateless components, "hidden" state, thread
safety
• Typical Spring application concerns
• Stateful components in Spring
Executor and ExecutorService
JDK Functionality
• Configurable thread pools
• Execute Runnables asynchronously
• Submit Callable<V> that returns Future<V>
Async Execution Considerations
• Blocking and timeouts
• Cancellation
• Interruption
• Thread Pool Rejection Policies
• Excessive thread creation
• Context-switching overhead
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
Asynchronous Execution
• Futures, executors, completion service and thread pools
• @Async
• Lifecycle and SmartLifecycle, cf. InitializingBean
• Gateways with Futures
• Timeouts
Spring Support for Task Management
• TaskExecutor
• TaskScheduler and Trigger
• @Async
• @Scheduled
• File-Polling adapter in Spring Integration
• Message listener containers
– JMS
– AMQP
– Spring Integration
– GemFire
• Spring Batch
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
Events and Intraprocess Communication
• The observer pattern: application and framework design
• ApplicationEvent and ApplicationListener
• Messaging
• SEDA
• Ordering
• Stateful Messaging patterns
Observer Pattern
Publisher
invoke(“input”)
confirmation
Multicaster
fire(“input”)
observe(“input”)
Observer
Event
ApplicationListener
// This is a listener
public class TransferListener implements
ApplicationListener<TransferEvent> {
public onApplicationEvent(TransferEvent event) {
this.auditLogger.log(event.getTransfer());
}
…
}
ApplicationEvent
java.util.Event
ApplicationEventPublisher
public class TransferService implements
ApplicationEventPublisherAware {
public setApplicationEventPublisher(
ApplicationEventPublisher publisher) {
this.publisher = publisher;
}
public void transfer(Transfer transfer) {
...
this.publisher.publish(new TransferEvent(transfer));
}
The Observer Pattern
Publisher
Multicaster
ObserverObserverObserverObserver
ApplicationListener
ApplicationContext
ApplicationEventPublisher
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
Messaging
• Decouple Producers and Consumers
• Observer Pattern but often with extra semantics
– header and payload
– publish-subscribe or point-to-point
– acks and nacks and other protocol details
– persistence and quality of service
– once-only or at-least-once delivery
widgets
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
Staged Event Driven Architecture (SEDA)
Staged Event Driven Architecture (SEDA)
Staged Event Driven Architecture (SEDA)
Staged Event Driven Architecture (SEDA)
Dispatcher
Queue
Ordering
• Multi-threaded applications in general do not preserve
order
• E.g. Messaging
– Producer sends two widgets 1, 2
– Consumer receives 2, 1
• To preserve order expect some overhead
– Storage (stateful patterns)
– Processing time (wait for out of order messages)
Stateful Messaging Patterns
• Scatter-Gather
• Composed Message Processor
• Claim Check
• Publish-Subscribe Channel
• Recipient List Router
• Splitter
• Multi-valued Router
• Aggregator
• Resequencer
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
Quality of Service, Transactions
Asynchronous hand off =
potential lost messages
Quality of Service, Transactions
Transactional (receive,
send) = no lost messages
Distributed Applications
• RPC, Spring Remoting
• Messaging
• Middleware: HTTP, JDBC, JMS, AMQP
• Latency
• QoS, transactions, durability and guaranteed delivery
• Distributed data: partitioning and eventual consistency
• Gemfire
• Spring Integration adapters
Distributed Application or System
• Application:
– Multiple JVM process nodes
– Same binaries
– Same release schedule
• System:
– Multiple JVM process nodes
– Different binaries
– Different release schedule per node
• Blurred boundary if Application has to have a rolling
upgrade with no downtime
Patterns of Distributed Transactions
• Full XA with 2PC
• XA with the 1PC Optimisation
• XA and the Last Resource Gambit
• Shared Transaction Resource
• Best Efforts 1PC
• Non-transactional Access
• Wing and a Prayer (anti-pattern)
http://www.javaworld.com/javaworld/jw-01-2009/jw-01-
spring-transactions.html
JTA + Spring
Spring Data +
Oracle
Spring JMS
Remote Procedure Call (RPC)
• RPC is synchronous inter-process communication
• Only evil if the system is not an Application
• Transports:
– RMI
– HTTP
– JMS
– JDBC
– ...
• Spring Remoting helps strategise and configure: defers
important architectural choices
• Spring Integration provides additional options
Messaging
• Messaging is asynchronous inter-process communication
• Can use Messaging to implement RPC
• Transports (some point-to-point only):
– RMI
– HTTP
– JMS
– JDBC
– AMQP
– ...
• Spring Integration: helps strategise and configure: defers
important architectural choices
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
Latency
• All distributed systems and applications suffer from
latency
– EU-US = 6000km, min network latency 6e6/3e8 = 20ms
– Add marshal/unmarshal overhead (variable)
– Transaction (min 50ms)
• Often much worse, e.g. >100ms even on local network
• Request-reply patterns double the problem
• Over-modularization: each inter-process hop is expensive
• Abstractions (e.g. Spring) are dangerous
• Measure and analyse
Distributed Application and Data
Nosql & Spring Data
• Key value stores
– redis, gemfire
– coherence
– riak, voldemort, memcached
• Document stores
– couchdb, mongodb
• Sparse table or column stores
– cassandra, bigtable
• Graph or object stores
– neo4j
• Distributed filesystem
– hdf
SpringSource Gemfire
• Distributed data cache, datastore and compute grid
• Java (so embeddable)
• Low-level API is java.util.Map
• Many high-level abstractions
– Transactions
– Functions and node affinity
– Events, continuous queries
– Replication
• Spring Gemfire:
http://git.springsource.org/spring-gemfire
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Demo
SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
Q&A
Source code for demos:
http://git.springsource.org/s2gx-2010/concurrent-programming-
distributed-applications
Distributed Transaction: Sunny Day
1. Start messaging transaction
2. Receive message
3. Start database transaction
4. Update database
5. Commit database transaction
6. Commit messaging transaction
Distributed Transaction: Rollback
1. Start messaging transaction
2. Receive message
3. Start database transaction
4. Update database, fail!
5. Rollback database transaction
6. Rollback messaging transaction
Distributed Transaction: Partial Failure
1. Start messaging transaction
2. Receive message
3. Start database transaction
4. Update database
5. Commit database transaction
6. Commit messaging transaction, fail!
Distributed Data: Shared Database
Application
Cache
Distributed Data: Cache Overflow
Cache
Distributed Cache: Database Meltdown
Distributed Data
Distributed Data

Weitere ähnliche Inhalte

Was ist angesagt?

Foreign Data Wrapper Enhancements
Foreign Data Wrapper EnhancementsForeign Data Wrapper Enhancements
Foreign Data Wrapper EnhancementsShigeru Hanada
 
Wayfair Use Case: The four R's of Metrics Delivery
Wayfair Use Case: The four R's of Metrics DeliveryWayfair Use Case: The four R's of Metrics Delivery
Wayfair Use Case: The four R's of Metrics DeliveryInfluxData
 
The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015craig lehmann
 
Enabling Vectorized Engine in Apache Spark
Enabling Vectorized Engine in Apache SparkEnabling Vectorized Engine in Apache Spark
Enabling Vectorized Engine in Apache SparkKazuaki Ishizaki
 
GPUs in Big Data - StampedeCon 2014
GPUs in Big Data - StampedeCon 2014GPUs in Big Data - StampedeCon 2014
GPUs in Big Data - StampedeCon 2014StampedeCon
 
Hadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm ArchitectureHadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm ArchitectureP. Taylor Goetz
 
Scaling Apache Storm (Hadoop Summit 2015)
Scaling Apache Storm (Hadoop Summit 2015)Scaling Apache Storm (Hadoop Summit 2015)
Scaling Apache Storm (Hadoop Summit 2015)Robert Evans
 
Realtime Analytics with Storm and Hadoop
Realtime Analytics with Storm and HadoopRealtime Analytics with Storm and Hadoop
Realtime Analytics with Storm and HadoopDataWorks Summit
 
Fault Tolerance in Spark: Lessons Learned from Production: Spark Summit East ...
Fault Tolerance in Spark: Lessons Learned from Production: Spark Summit East ...Fault Tolerance in Spark: Lessons Learned from Production: Spark Summit East ...
Fault Tolerance in Spark: Lessons Learned from Production: Spark Summit East ...Spark Summit
 
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...InfluxData
 
Apache Storm 0.9 basic training - Verisign
Apache Storm 0.9 basic training - VerisignApache Storm 0.9 basic training - Verisign
Apache Storm 0.9 basic training - VerisignMichael Noll
 
Make AI ecosystem more interoperable
Make AI ecosystem more interoperableMake AI ecosystem more interoperable
Make AI ecosystem more interoperableKazuaki Ishizaki
 
Fighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with EmbulkFighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with EmbulkSadayuki Furuhashi
 
Fluentd at Bay Area Kubernetes Meetup
Fluentd at Bay Area Kubernetes MeetupFluentd at Bay Area Kubernetes Meetup
Fluentd at Bay Area Kubernetes MeetupSadayuki Furuhashi
 
Real-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache StormReal-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache StormDavorin Vukelic
 
How to build your own OpenStack distro using Puppet OpenStack
How to build your own OpenStack distro using Puppet OpenStackHow to build your own OpenStack distro using Puppet OpenStack
How to build your own OpenStack distro using Puppet OpenStackOpenStack
 

Was ist angesagt? (20)

Foreign Data Wrapper Enhancements
Foreign Data Wrapper EnhancementsForeign Data Wrapper Enhancements
Foreign Data Wrapper Enhancements
 
Wayfair Use Case: The four R's of Metrics Delivery
Wayfair Use Case: The four R's of Metrics DeliveryWayfair Use Case: The four R's of Metrics Delivery
Wayfair Use Case: The four R's of Metrics Delivery
 
The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015The OMR GC talk - Ruby Kaigi 2015
The OMR GC talk - Ruby Kaigi 2015
 
Enabling Vectorized Engine in Apache Spark
Enabling Vectorized Engine in Apache SparkEnabling Vectorized Engine in Apache Spark
Enabling Vectorized Engine in Apache Spark
 
GPUs in Big Data - StampedeCon 2014
GPUs in Big Data - StampedeCon 2014GPUs in Big Data - StampedeCon 2014
GPUs in Big Data - StampedeCon 2014
 
Hadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm ArchitectureHadoop Summit Europe 2014: Apache Storm Architecture
Hadoop Summit Europe 2014: Apache Storm Architecture
 
Scaling Apache Storm (Hadoop Summit 2015)
Scaling Apache Storm (Hadoop Summit 2015)Scaling Apache Storm (Hadoop Summit 2015)
Scaling Apache Storm (Hadoop Summit 2015)
 
Cascalog internal dsl_preso
Cascalog internal dsl_presoCascalog internal dsl_preso
Cascalog internal dsl_preso
 
Realtime Analytics with Storm and Hadoop
Realtime Analytics with Storm and HadoopRealtime Analytics with Storm and Hadoop
Realtime Analytics with Storm and Hadoop
 
Fault Tolerance in Spark: Lessons Learned from Production: Spark Summit East ...
Fault Tolerance in Spark: Lessons Learned from Production: Spark Summit East ...Fault Tolerance in Spark: Lessons Learned from Production: Spark Summit East ...
Fault Tolerance in Spark: Lessons Learned from Production: Spark Summit East ...
 
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
How to Introduce Telemetry Streaming (gNMI) in Your Network with SNMP with Te...
 
icpe2019_ishizaki_public
icpe2019_ishizaki_publicicpe2019_ishizaki_public
icpe2019_ishizaki_public
 
Apache Storm 0.9 basic training - Verisign
Apache Storm 0.9 basic training - VerisignApache Storm 0.9 basic training - Verisign
Apache Storm 0.9 basic training - Verisign
 
Make AI ecosystem more interoperable
Make AI ecosystem more interoperableMake AI ecosystem more interoperable
Make AI ecosystem more interoperable
 
Fighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with EmbulkFighting Against Chaotically Separated Values with Embulk
Fighting Against Chaotically Separated Values with Embulk
 
Fluentd at Bay Area Kubernetes Meetup
Fluentd at Bay Area Kubernetes MeetupFluentd at Bay Area Kubernetes Meetup
Fluentd at Bay Area Kubernetes Meetup
 
Real-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache StormReal-Time Streaming with Apache Spark Streaming and Apache Storm
Real-Time Streaming with Apache Spark Streaming and Apache Storm
 
Python at Facebook
Python at FacebookPython at Facebook
Python at Facebook
 
Embuk internals
Embuk internalsEmbuk internals
Embuk internals
 
How to build your own OpenStack distro using Puppet OpenStack
How to build your own OpenStack distro using Puppet OpenStackHow to build your own OpenStack distro using Puppet OpenStack
How to build your own OpenStack distro using Puppet OpenStack
 

Ähnlich wie Concurrency (Fisher Syer S2GX 2010)

Instrumenting the real-time web: Node.js in production
Instrumenting the real-time web: Node.js in productionInstrumenting the real-time web: Node.js in production
Instrumenting the real-time web: Node.js in productionbcantrill
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.jsorkaplan
 
Integrate Solr with real-time stream processing applications
Integrate Solr with real-time stream processing applicationsIntegrate Solr with real-time stream processing applications
Integrate Solr with real-time stream processing applicationsthelabdude
 
Stream Processing in the Cloud With Data Microservices
Stream Processing in the Cloud With Data MicroservicesStream Processing in the Cloud With Data Microservices
Stream Processing in the Cloud With Data Microservicesmarius_bogoevici
 
StarlingX - Project Onboarding
StarlingX - Project OnboardingStarlingX - Project Onboarding
StarlingX - Project OnboardingShuquan Huang
 
Building a system for machine and event-oriented data - SF HUG Nov 2015
Building a system for machine and event-oriented data - SF HUG Nov 2015Building a system for machine and event-oriented data - SF HUG Nov 2015
Building a system for machine and event-oriented data - SF HUG Nov 2015Felicia Haggarty
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm Chandler Huang
 
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...HostedbyConfluent
 
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014NoSQLmatters
 
DSD-INT 2015 - RSS Sentinel Toolbox - J. Manuel Delgado Blasco
DSD-INT 2015 - RSS Sentinel Toolbox - J. Manuel Delgado BlascoDSD-INT 2015 - RSS Sentinel Toolbox - J. Manuel Delgado Blasco
DSD-INT 2015 - RSS Sentinel Toolbox - J. Manuel Delgado BlascoDeltares
 
PEARC17: Live Integrated Visualization Environment: An Experiment in General...
PEARC17: Live Integrated Visualization Environment: An Experiment in General...PEARC17: Live Integrated Visualization Environment: An Experiment in General...
PEARC17: Live Integrated Visualization Environment: An Experiment in General...moneyjh
 
How to Make Norikra Perfect
How to Make Norikra PerfectHow to Make Norikra Perfect
How to Make Norikra PerfectSATOSHI TAGOMORI
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examplesPeter Lawrey
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8amix3k
 
Cyclone DDS Unleashed: Scalability in DDS and Dealing with Large Systems
Cyclone DDS Unleashed: Scalability in DDS and Dealing with Large SystemsCyclone DDS Unleashed: Scalability in DDS and Dealing with Large Systems
Cyclone DDS Unleashed: Scalability in DDS and Dealing with Large SystemsZettaScaleTechnology
 
Groovy concurrency
Groovy concurrencyGroovy concurrency
Groovy concurrencyAlex Miller
 
Hidden pearls for High-Performance-Persistence
Hidden pearls for High-Performance-PersistenceHidden pearls for High-Performance-Persistence
Hidden pearls for High-Performance-PersistenceSven Ruppert
 
HPC and cloud distributed computing, as a journey
HPC and cloud distributed computing, as a journeyHPC and cloud distributed computing, as a journey
HPC and cloud distributed computing, as a journeyPeter Clapham
 

Ähnlich wie Concurrency (Fisher Syer S2GX 2010) (20)

Instrumenting the real-time web: Node.js in production
Instrumenting the real-time web: Node.js in productionInstrumenting the real-time web: Node.js in production
Instrumenting the real-time web: Node.js in production
 
introduction to node.js
introduction to node.jsintroduction to node.js
introduction to node.js
 
Integrate Solr with real-time stream processing applications
Integrate Solr with real-time stream processing applicationsIntegrate Solr with real-time stream processing applications
Integrate Solr with real-time stream processing applications
 
Stream Processing in the Cloud With Data Microservices
Stream Processing in the Cloud With Data MicroservicesStream Processing in the Cloud With Data Microservices
Stream Processing in the Cloud With Data Microservices
 
Chapter 6 os
Chapter 6 osChapter 6 os
Chapter 6 os
 
StarlingX - Project Onboarding
StarlingX - Project OnboardingStarlingX - Project Onboarding
StarlingX - Project Onboarding
 
Building a system for machine and event-oriented data - SF HUG Nov 2015
Building a system for machine and event-oriented data - SF HUG Nov 2015Building a system for machine and event-oriented data - SF HUG Nov 2015
Building a system for machine and event-oriented data - SF HUG Nov 2015
 
Introduction to Storm
Introduction to Storm Introduction to Storm
Introduction to Storm
 
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
Developing Kafka Streams Applications with Upgradability in Mind with Neil Bu...
 
Spark etl
Spark etlSpark etl
Spark etl
 
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
Johnny Miller – Cassandra + Spark = Awesome- NoSQL matters Barcelona 2014
 
DSD-INT 2015 - RSS Sentinel Toolbox - J. Manuel Delgado Blasco
DSD-INT 2015 - RSS Sentinel Toolbox - J. Manuel Delgado BlascoDSD-INT 2015 - RSS Sentinel Toolbox - J. Manuel Delgado Blasco
DSD-INT 2015 - RSS Sentinel Toolbox - J. Manuel Delgado Blasco
 
PEARC17: Live Integrated Visualization Environment: An Experiment in General...
PEARC17: Live Integrated Visualization Environment: An Experiment in General...PEARC17: Live Integrated Visualization Environment: An Experiment in General...
PEARC17: Live Integrated Visualization Environment: An Experiment in General...
 
How to Make Norikra Perfect
How to Make Norikra PerfectHow to Make Norikra Perfect
How to Make Norikra Perfect
 
Reactive programming with examples
Reactive programming with examplesReactive programming with examples
Reactive programming with examples
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
 
Cyclone DDS Unleashed: Scalability in DDS and Dealing with Large Systems
Cyclone DDS Unleashed: Scalability in DDS and Dealing with Large SystemsCyclone DDS Unleashed: Scalability in DDS and Dealing with Large Systems
Cyclone DDS Unleashed: Scalability in DDS and Dealing with Large Systems
 
Groovy concurrency
Groovy concurrencyGroovy concurrency
Groovy concurrency
 
Hidden pearls for High-Performance-Persistence
Hidden pearls for High-Performance-PersistenceHidden pearls for High-Performance-Persistence
Hidden pearls for High-Performance-Persistence
 
HPC and cloud distributed computing, as a journey
HPC and cloud distributed computing, as a journeyHPC and cloud distributed computing, as a journey
HPC and cloud distributed computing, as a journey
 

Kürzlich hochgeladen

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 

Kürzlich hochgeladen (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 

Concurrency (Fisher Syer S2GX 2010)

  • 1. Chicago, October 19 - 22, 2010 Concurrent Programming and Distributed Applications Mark Fisher, Dave Syer - SpringSource
  • 2. Goal ● Demystify concurrent and distributed programming. ● Identify and help avoid the pitfalls ● Show how Spring makes it easier to write multi- threaded and multi-process applications
  • 3. Agenda • Concurrency • Asynchronous execution • Tasks, schedules and triggers • Events, Messaging and intra-process communication • Distributed systems
  • 4. Concurrency SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Why? - Performance - Responsiveness - Scalability Where? - Event-driven Architecture - Scheduling Tasks
  • 5. When threads were more esoteric, concurrency was an "advanced" topic; now, mainstream developers must be aware of thread-safety issues. --Brian Goetz
  • 6. Thread Safe? SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. public class Counter { private boolean active = false; public boolean isActive() { return active; } public void setActive(boolean active) { this.active = active; } }
  • 7. Thread Safe? SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. public class Counter { private volatile int count = 0; public int increment() { return count++; } }
  • 8. Thread Safe? SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. public class Service { private volatile Resource resource; public void process(String data) { if (this.resource == null) { this.resource = new Resource(); } this.resource.process(data); } }
  • 9. Thread Safety SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. What? Properly managing concurrent access to mutable state. How? a) avoid mutability b) don't share c) synchronize
  • 10. Immutable? public class StringHolder { private final int id; private final String value; public StringHolder(int id, String value) { this.id = id; this.value = value; } public void display() { Sysem.out.println(id + ": " + this.value); } } SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 11. Immutable? public class StringList { private final int id; private final List<String> strings; public StringList(int id, List<String> strings) { this.id = id; this.strings = strings; } public void display() { Sysem.out.println(id + ": " + this.strings); } } SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 12. Immutable? public class MapHolder { private final Map<Integer, StringValue> map; public MapHolder(Map<Integer, StringValue> map) { this.map = new HashMap<Integer, StringValue>(map); } public void display() { System.out.println(this.map); } } SpringOne 2GX 2010. All rights reserved. Do not distribute without permission.
  • 13. Immutable? private final Map<Integer, StringValue> map; public MapHolder(Map<Integer, StringValue> map) { this.map = new HashMap<Integer, StringValue>(map); } SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. public static class StringValue { private String string; public StringValue(String string) { this.string = string; } public void setString(String string) { this.string = string; } } public static class StringValue { private String string; public StringValue(String string) { this.string = string; } public void setString(String string) { this.string = string; } }
  • 14. Immutable? private final Map<Integer, StringValue> map; public MapHolder(Map<Integer, StringValue> map) { this.map = new HashMap<Integer, StringValue>(map); } SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. public static class StringValue { private final String string; public StringValue(String string) { this.string = string; } } public static class StringValue { private final String string; public StringValue(String string) { this.string = string; } }
  • 15. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 16. Thread Safety: Confinement When immutability is not an option, consider not sharing mutable state • Stack Confinement – Method Parameters – Local Variables • Thread Confinement – ThreadLocal – Custom Scopes in Spring
  • 17. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 18. Synchronization • The 'synchronized' keyword • Locks • wait/notify • Atomic variables
  • 19. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 20. Lazy Initialization (recap) SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. public class Service { private volatile Resource resource; public void process(String data) { if (this.resource == null) { this.resource = new Resource(); } this.resource.process(data); } }
  • 21. Dependency Injection and Singletons SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. public class Service { private volatile Resource resource; public void setResource(Resources resource) { this.resource = resource; } public void process(String data) { this.resource.process(data); } }
  • 22. Concurrency • Background processing and performance optimization • Java Memory Model: final, volatile, synchronized • Locks: wait, notify, utility wrappers • Concurrent collections, immutable wrappers • Queue, BlockingQueue, DelayQueue • Deadlock, livelock, starvation • Immutability, stateless components, "hidden" state, thread safety • Typical Spring application concerns • Stateful components in Spring
  • 23. Executor and ExecutorService JDK Functionality • Configurable thread pools • Execute Runnables asynchronously • Submit Callable<V> that returns Future<V>
  • 24. Async Execution Considerations • Blocking and timeouts • Cancellation • Interruption • Thread Pool Rejection Policies • Excessive thread creation • Context-switching overhead
  • 25. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 26. Asynchronous Execution • Futures, executors, completion service and thread pools • @Async • Lifecycle and SmartLifecycle, cf. InitializingBean • Gateways with Futures • Timeouts
  • 27. Spring Support for Task Management • TaskExecutor • TaskScheduler and Trigger • @Async • @Scheduled • File-Polling adapter in Spring Integration • Message listener containers – JMS – AMQP – Spring Integration – GemFire • Spring Batch
  • 28. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 29. Events and Intraprocess Communication • The observer pattern: application and framework design • ApplicationEvent and ApplicationListener • Messaging • SEDA • Ordering • Stateful Messaging patterns
  • 31. ApplicationListener // This is a listener public class TransferListener implements ApplicationListener<TransferEvent> { public onApplicationEvent(TransferEvent event) { this.auditLogger.log(event.getTransfer()); } … } ApplicationEvent java.util.Event
  • 32. ApplicationEventPublisher public class TransferService implements ApplicationEventPublisherAware { public setApplicationEventPublisher( ApplicationEventPublisher publisher) { this.publisher = publisher; } public void transfer(Transfer transfer) { ... this.publisher.publish(new TransferEvent(transfer)); }
  • 34. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 35. Messaging • Decouple Producers and Consumers • Observer Pattern but often with extra semantics – header and payload – publish-subscribe or point-to-point – acks and nacks and other protocol details – persistence and quality of service – once-only or at-least-once delivery widgets
  • 36. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 37. Staged Event Driven Architecture (SEDA)
  • 38. Staged Event Driven Architecture (SEDA)
  • 39. Staged Event Driven Architecture (SEDA)
  • 40. Staged Event Driven Architecture (SEDA) Dispatcher Queue
  • 41. Ordering • Multi-threaded applications in general do not preserve order • E.g. Messaging – Producer sends two widgets 1, 2 – Consumer receives 2, 1 • To preserve order expect some overhead – Storage (stateful patterns) – Processing time (wait for out of order messages)
  • 42. Stateful Messaging Patterns • Scatter-Gather • Composed Message Processor • Claim Check • Publish-Subscribe Channel • Recipient List Router • Splitter • Multi-valued Router • Aggregator • Resequencer
  • 43. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 44. Quality of Service, Transactions Asynchronous hand off = potential lost messages
  • 45. Quality of Service, Transactions Transactional (receive, send) = no lost messages
  • 46. Distributed Applications • RPC, Spring Remoting • Messaging • Middleware: HTTP, JDBC, JMS, AMQP • Latency • QoS, transactions, durability and guaranteed delivery • Distributed data: partitioning and eventual consistency • Gemfire • Spring Integration adapters
  • 47. Distributed Application or System • Application: – Multiple JVM process nodes – Same binaries – Same release schedule • System: – Multiple JVM process nodes – Different binaries – Different release schedule per node • Blurred boundary if Application has to have a rolling upgrade with no downtime
  • 48. Patterns of Distributed Transactions • Full XA with 2PC • XA with the 1PC Optimisation • XA and the Last Resource Gambit • Shared Transaction Resource • Best Efforts 1PC • Non-transactional Access • Wing and a Prayer (anti-pattern) http://www.javaworld.com/javaworld/jw-01-2009/jw-01- spring-transactions.html JTA + Spring Spring Data + Oracle Spring JMS
  • 49. Remote Procedure Call (RPC) • RPC is synchronous inter-process communication • Only evil if the system is not an Application • Transports: – RMI – HTTP – JMS – JDBC – ... • Spring Remoting helps strategise and configure: defers important architectural choices • Spring Integration provides additional options
  • 50. Messaging • Messaging is asynchronous inter-process communication • Can use Messaging to implement RPC • Transports (some point-to-point only): – RMI – HTTP – JMS – JDBC – AMQP – ... • Spring Integration: helps strategise and configure: defers important architectural choices
  • 51. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 52. Latency • All distributed systems and applications suffer from latency – EU-US = 6000km, min network latency 6e6/3e8 = 20ms – Add marshal/unmarshal overhead (variable) – Transaction (min 50ms) • Often much worse, e.g. >100ms even on local network • Request-reply patterns double the problem • Over-modularization: each inter-process hop is expensive • Abstractions (e.g. Spring) are dangerous • Measure and analyse
  • 54. Nosql & Spring Data • Key value stores – redis, gemfire – coherence – riak, voldemort, memcached • Document stores – couchdb, mongodb • Sparse table or column stores – cassandra, bigtable • Graph or object stores – neo4j • Distributed filesystem – hdf
  • 55. SpringSource Gemfire • Distributed data cache, datastore and compute grid • Java (so embeddable) • Low-level API is java.util.Map • Many high-level abstractions – Transactions – Functions and node affinity – Events, continuous queries – Replication • Spring Gemfire: http://git.springsource.org/spring-gemfire
  • 56. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Demo
  • 57. SpringOne 2GX 2010. All rights reserved. Do not distribute without permission. Q&A Source code for demos: http://git.springsource.org/s2gx-2010/concurrent-programming- distributed-applications
  • 58. Distributed Transaction: Sunny Day 1. Start messaging transaction 2. Receive message 3. Start database transaction 4. Update database 5. Commit database transaction 6. Commit messaging transaction
  • 59. Distributed Transaction: Rollback 1. Start messaging transaction 2. Receive message 3. Start database transaction 4. Update database, fail! 5. Rollback database transaction 6. Rollback messaging transaction
  • 60. Distributed Transaction: Partial Failure 1. Start messaging transaction 2. Receive message 3. Start database transaction 4. Update database 5. Commit database transaction 6. Commit messaging transaction, fail!
  • 61. Distributed Data: Shared Database Application Cache
  • 62. Distributed Data: Cache Overflow Cache