SlideShare a Scribd company logo
THE ILLUSION OF STATELESSNESS
ALEKSANDAR SEOVIC
Architect, Oracle Coherence
See all the presentations from the In-Memory Computing
Summit at http://imcsummit.org
WARNING
STUPID SHIT YOU CAN FIND ON THE WEB, TAKE 1
Bottom line: Stateless apps are ideal.
Server-side database writes are your enemy. If you
must save state, save it on the client. Use cookies and
Ajax where appropriate.
If you follow this rule, you will multiply your scalability.
STUPID S#!T YOU CAN FIND ON THE WEB, TAKE 1
Bottom line: Stateless apps are ideal.
Server-side database writes are your enemy. If you
must save state, save it on the client. Use cookies and
Ajax where appropriate.
If you follow this rule, you will multiply your scalability.
STUPID SHIT YOU CAN FIND ON THE WEB, TAKE 1
Bottom line: Stateless apps are ideal.
Server-side database writes are your enemy. If you
must save state, save it on the client. Use cookies and
Ajax where appropriate.
If you follow this rule, you will multiply your scalability.
STUPID SHIT YOU CAN FIND ON THE WEB, TAKE 2
Services should be stateless. One benefit that you get from
this is scalability. You can move expensive operations to a
cluster of dedicated machines and it does not matter which
one responds to a particular request since all of them are
independent.
STUPID S#!T YOU CAN FIND ON THE WEB, TAKE 2
Services should be stateless. One benefit that you get from
this is scalability. You can move expensive operations to a
cluster of dedicated machines and it does not matter which
one responds to a particular request since all of them are
independent.
STUPID SHIT YOU CAN FIND ON THE WEB, TAKE 2
Services should be stateless. One benefit that you get from
this is scalability. You can move expensive operations to a
cluster of dedicated machines and it does not matter which
one responds to a particular request since all of them are
independent.
AND FINALLY SOMEONE WITH A SENSE OF HUMOR…
http://whatis.techtarget.com/definition/stateless
AND FINALLY SOMEONE WITH A SENSE OF HUMOR…
http://whatis.techtarget.com/definition/stateless
AND FINALLY SOMEONE WITH A SENSE OF HUMOR…
http://whatis.techtarget.com/definition/stateless
FACT #1
HTTP protocol is stateless
FACT #2
But your RESTful service is not
AN EXAMPLE OF A TRULY STATELESS SERVICE
@Path("calc")
public class Calculator
{
@GET
@Path("add")
public int add(@QueryParam("x") int x, @QueryParam("y") int y)
{
return x + y;
}
}
AN EXAMPLE OF A “STATELESS” SERVICE
@Path("cart")
public class CartService
{
@POST
public Response addItem(
@CookieParam("user.id") String userId,
@FormParam("sku") String sku,
@FormParam("price") BigDecimal price)
{
Cart cart = cartDao.getCartForUser(userId);
cart.add(sku, price, 1);
cartDao.save(cart);
return Response.ok().build();
}
@Inject
private CartDao cartDao;
}
MYTH
“Stateless” services scale better
(REALLY) LIVE DEMO
NEED A FEW VOLUNTEERS…
FACT #3
“Stateless” services scale only as
good as the state management
layer they depend on
BIG QUESTION
So how do we really build scalable
services and applications then?
RULE #1
Separate state management and
durability aspects.
Manage state in memory, using
technology that allows you to scale.
EXAMPLE: LIGHTBEND LAGOM
EXAMPLE: ORACLE COHERENCE
EXAMPLE: APACHE IGNITE
EXAMPLE: ON DISK DURABILITY
EXAMPLE: MULTI-DATACENTER DURABILITY
RULE #2
Don’t move data unless you
absolutely have to.
Send operations to the data instead.
AN EXAMPLE: NEAR CACHING
AN EXAMPLE: JAVA 8 LAMBDAS
@Path("cart")
public class CartService
{
@POST
public Response addItem(
@CookieParam("user.id") String userId,
@FormParam("sku") String sku,
@FormParam("price") BigDecimal price)
{
cartDao.process(userId, cart -> cart.add(sku, price, 1));
return Response.ok().build();
}
@Inject
private CartDao cartDao;
}
AN EXAMPLE: COHERENCE 12.2.1 DISTRIBUTED LAMBDAS
public <R> R process(String userId, Remote.Function<Cart, R> cartFunction)
{
return carts.invoke(userId, entry ->
{
Cart cart = entry.getValue();
R result = cartFunction.apply(cart);
entry.setValue(cart);
return result;
});
}
RULE #3
Do whatever you can
asynchronously
AN EXAMPLE: AT THE ARCHITECTURAL LEVEL
Is REST truly the best?
AN EXAMPLE: JAVA 8 CompletableFuture
// synchronous
cache.put(1, "Aleks");
// asynchronous
cache.async().put(1, "Aleks");
// synchronous
System.out.println("Name: " + cache.get(1));
// asynchronous
cache.async().get(1)
.thenAccept(name -> System.out.println("Name: " + name));
AN EXAMPLE: REACTIVE EXTENSIONS
// reactive
Observable<Void> observable = rx(cache).put(1, "Aleks");
rx(cache).get(1)
.subscribe(name -> System.out.println("Name: " + name));
https://github.com/coherence-community/coherence-
rx
CoherenceRx
RULE #4
Model complex processes as finite
state machines, and use events to
trigger state transitions
AN EXAMPLE: ORDER PROCESSING
RULE #5
Don’t use global locks, counters or
other stupid shit that prevents you
from scaling out.
EXAMPLES (OF WHAT NOT TO DO)
EXAMPLES (OF WHAT NOT TO DO)
EXAMPLES (OF WHAT NOT TO DO)
RECOMMENDED
READING
Q & A
THANK YOU!
Q & A
THANK YOU!

More Related Content

Viewers also liked

Viewers also liked (6)

Oracle Coherence: in-memory datagrid
Oracle Coherence: in-memory datagridOracle Coherence: in-memory datagrid
Oracle Coherence: in-memory datagrid
 
Indexes and Indexing in Oracle 12c
Indexes and Indexing in Oracle 12cIndexes and Indexing in Oracle 12c
Indexes and Indexing in Oracle 12c
 
Write Less (code) With More (Oracle Database 12c New Features)
Write Less (code) With More (Oracle Database 12c New Features)Write Less (code) With More (Oracle Database 12c New Features)
Write Less (code) With More (Oracle Database 12c New Features)
 
Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!Java 9: The (G1) GC Awakens!
Java 9: The (G1) GC Awakens!
 
Project Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To JavaProject Jigsaw in JDK 9: Modularity Comes To Java
Project Jigsaw in JDK 9: Modularity Comes To Java
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 

Similar to IMC Summit 2016 Breakout - Aleksandar Seovic - The Illusion of Statelessness

AWS Cloud Kata 2014 | Jakarta - Startup Best Practices
AWS Cloud Kata 2014 | Jakarta - Startup Best PracticesAWS Cloud Kata 2014 | Jakarta - Startup Best Practices
AWS Cloud Kata 2014 | Jakarta - Startup Best Practices
Amazon Web Services
 
AWS Startup Webinar | Developing on AWS
AWS Startup Webinar | Developing on AWSAWS Startup Webinar | Developing on AWS
AWS Startup Webinar | Developing on AWS
Amazon Web Services
 

Similar to IMC Summit 2016 Breakout - Aleksandar Seovic - The Illusion of Statelessness (20)

Cloud Expo Silicon Valley 2013 | Why Lease When You Can Buy Your Cloud
Cloud Expo Silicon Valley 2013 | Why Lease When You Can Buy Your CloudCloud Expo Silicon Valley 2013 | Why Lease When You Can Buy Your Cloud
Cloud Expo Silicon Valley 2013 | Why Lease When You Can Buy Your Cloud
 
AWS Cloud Kata 2014 | Jakarta - Startup Best Practices
AWS Cloud Kata 2014 | Jakarta - Startup Best PracticesAWS Cloud Kata 2014 | Jakarta - Startup Best Practices
AWS Cloud Kata 2014 | Jakarta - Startup Best Practices
 
Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016Microservices with .Net - NDC Sydney, 2016
Microservices with .Net - NDC Sydney, 2016
 
AWS Startup Webinar | Developing on AWS
AWS Startup Webinar | Developing on AWSAWS Startup Webinar | Developing on AWS
AWS Startup Webinar | Developing on AWS
 
Debunking serverless myths
Debunking serverless mythsDebunking serverless myths
Debunking serverless myths
 
AWS Startup Insights Kuala Lumpur
AWS Startup Insights Kuala LumpurAWS Startup Insights Kuala Lumpur
AWS Startup Insights Kuala Lumpur
 
Evolution of Microservices - Craft Conference
Evolution of Microservices - Craft ConferenceEvolution of Microservices - Craft Conference
Evolution of Microservices - Craft Conference
 
Architecting Microservices in .Net
Architecting Microservices in .NetArchitecting Microservices in .Net
Architecting Microservices in .Net
 
LinuxCon North America 2013: Why Lease When You Can Buy Your Cloud
LinuxCon North America 2013: Why Lease When You Can Buy Your CloudLinuxCon North America 2013: Why Lease When You Can Buy Your Cloud
LinuxCon North America 2013: Why Lease When You Can Buy Your Cloud
 
Internet Scale Architecture
Internet Scale ArchitectureInternet Scale Architecture
Internet Scale Architecture
 
Abusing the Cloud for Fun and Profit
Abusing the Cloud for Fun and ProfitAbusing the Cloud for Fun and Profit
Abusing the Cloud for Fun and Profit
 
Angular js mobile jsday 2014 - Verona 14 may
Angular js mobile   jsday 2014 - Verona 14 mayAngular js mobile   jsday 2014 - Verona 14 may
Angular js mobile jsday 2014 - Verona 14 may
 
AWS Startup Insights Singapore
AWS Startup Insights SingaporeAWS Startup Insights Singapore
AWS Startup Insights Singapore
 
Clues for Solving Cloud-Based App Performance
Clues for Solving Cloud-Based App Performance Clues for Solving Cloud-Based App Performance
Clues for Solving Cloud-Based App Performance
 
The Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To KnowThe Ember.js Framework - Everything You Need To Know
The Ember.js Framework - Everything You Need To Know
 
Matt Johnson - My developer journey towards true hybrid cloud with Kubernetes...
Matt Johnson - My developer journey towards true hybrid cloud with Kubernetes...Matt Johnson - My developer journey towards true hybrid cloud with Kubernetes...
Matt Johnson - My developer journey towards true hybrid cloud with Kubernetes...
 
Low latency in java 8 by Peter Lawrey
Low latency in java 8 by Peter Lawrey Low latency in java 8 by Peter Lawrey
Low latency in java 8 by Peter Lawrey
 
Debunking serverless myths
Debunking serverless mythsDebunking serverless myths
Debunking serverless myths
 
Deep Dive: AWS X-Ray London Summit 2017
Deep Dive: AWS X-Ray London Summit 2017Deep Dive: AWS X-Ray London Summit 2017
Deep Dive: AWS X-Ray London Summit 2017
 
20141021 AWS Cloud Taekwon - Startup Best Practices on AWS
20141021 AWS Cloud Taekwon - Startup Best Practices on AWS20141021 AWS Cloud Taekwon - Startup Best Practices on AWS
20141021 AWS Cloud Taekwon - Startup Best Practices on AWS
 

More from In-Memory Computing Summit

IMC Summit 2016 Breakout - Nikita Shamgunov - Propelling IoT Innovation with ...
IMC Summit 2016 Breakout - Nikita Shamgunov - Propelling IoT Innovation with ...IMC Summit 2016 Breakout - Nikita Shamgunov - Propelling IoT Innovation with ...
IMC Summit 2016 Breakout - Nikita Shamgunov - Propelling IoT Innovation with ...
In-Memory Computing Summit
 
IMC Summit 2016 Innovation - Girish Mutreja - Unveiling the X Platform
IMC Summit 2016 Innovation - Girish Mutreja - Unveiling the X PlatformIMC Summit 2016 Innovation - Girish Mutreja - Unveiling the X Platform
IMC Summit 2016 Innovation - Girish Mutreja - Unveiling the X Platform
In-Memory Computing Summit
 
IMC Summit 2016 Breakout - Yanping Wang - Non-volatile Generic Object Program...
IMC Summit 2016 Breakout - Yanping Wang - Non-volatile Generic Object Program...IMC Summit 2016 Breakout - Yanping Wang - Non-volatile Generic Object Program...
IMC Summit 2016 Breakout - Yanping Wang - Non-volatile Generic Object Program...
In-Memory Computing Summit
 
IMC Summit 2016 Breakout - Girish Mutreja - Extreme Transaction Processing in...
IMC Summit 2016 Breakout - Girish Mutreja - Extreme Transaction Processing in...IMC Summit 2016 Breakout - Girish Mutreja - Extreme Transaction Processing in...
IMC Summit 2016 Breakout - Girish Mutreja - Extreme Transaction Processing in...
In-Memory Computing Summit
 

More from In-Memory Computing Summit (20)

IMC Summit 2016 Breakout - Per Minoborg - Work with Multiple Hot Terabytes in...
IMC Summit 2016 Breakout - Per Minoborg - Work with Multiple Hot Terabytes in...IMC Summit 2016 Breakout - Per Minoborg - Work with Multiple Hot Terabytes in...
IMC Summit 2016 Breakout - Per Minoborg - Work with Multiple Hot Terabytes in...
 
IMC Summit 2016 Breakout - Henning Andersen - Using Lock-free and Wait-free I...
IMC Summit 2016 Breakout - Henning Andersen - Using Lock-free and Wait-free I...IMC Summit 2016 Breakout - Henning Andersen - Using Lock-free and Wait-free I...
IMC Summit 2016 Breakout - Henning Andersen - Using Lock-free and Wait-free I...
 
IMC Summit 2016 Breakout - Roman Shtykh - Apache Ignite as a Data Processing Hub
IMC Summit 2016 Breakout - Roman Shtykh - Apache Ignite as a Data Processing HubIMC Summit 2016 Breakout - Roman Shtykh - Apache Ignite as a Data Processing Hub
IMC Summit 2016 Breakout - Roman Shtykh - Apache Ignite as a Data Processing Hub
 
IMC Summit 2016 Breakout - Nikita Shamgunov - Propelling IoT Innovation with ...
IMC Summit 2016 Breakout - Nikita Shamgunov - Propelling IoT Innovation with ...IMC Summit 2016 Breakout - Nikita Shamgunov - Propelling IoT Innovation with ...
IMC Summit 2016 Breakout - Nikita Shamgunov - Propelling IoT Innovation with ...
 
IMC Summit 2016 Breakout - Matt Coventon - Test Driving Streaming and CEP on ...
IMC Summit 2016 Breakout - Matt Coventon - Test Driving Streaming and CEP on ...IMC Summit 2016 Breakout - Matt Coventon - Test Driving Streaming and CEP on ...
IMC Summit 2016 Breakout - Matt Coventon - Test Driving Streaming and CEP on ...
 
IMC Summit 2016 Innovation - Derek Nelson - PipelineDB: The Streaming-SQL Dat...
IMC Summit 2016 Innovation - Derek Nelson - PipelineDB: The Streaming-SQL Dat...IMC Summit 2016 Innovation - Derek Nelson - PipelineDB: The Streaming-SQL Dat...
IMC Summit 2016 Innovation - Derek Nelson - PipelineDB: The Streaming-SQL Dat...
 
IMC Summit 2016 Innovation - Dennis Duckworth - Lambda-B-Gone: The In-memory ...
IMC Summit 2016 Innovation - Dennis Duckworth - Lambda-B-Gone: The In-memory ...IMC Summit 2016 Innovation - Dennis Duckworth - Lambda-B-Gone: The In-memory ...
IMC Summit 2016 Innovation - Dennis Duckworth - Lambda-B-Gone: The In-memory ...
 
IMC Summit 2016 Innovation - Steve Wilkes - Tap Into Your Enterprise – Why Da...
IMC Summit 2016 Innovation - Steve Wilkes - Tap Into Your Enterprise – Why Da...IMC Summit 2016 Innovation - Steve Wilkes - Tap Into Your Enterprise – Why Da...
IMC Summit 2016 Innovation - Steve Wilkes - Tap Into Your Enterprise – Why Da...
 
IMC Summit 2016 Innovation - Girish Mutreja - Unveiling the X Platform
IMC Summit 2016 Innovation - Girish Mutreja - Unveiling the X PlatformIMC Summit 2016 Innovation - Girish Mutreja - Unveiling the X Platform
IMC Summit 2016 Innovation - Girish Mutreja - Unveiling the X Platform
 
IMC Summit 2016 Breakout - Ken Gibson - The In-Place Working Storage Tier
IMC Summit 2016 Breakout - Ken Gibson - The In-Place Working Storage TierIMC Summit 2016 Breakout - Ken Gibson - The In-Place Working Storage Tier
IMC Summit 2016 Breakout - Ken Gibson - The In-Place Working Storage Tier
 
IMC Summit 2016 Breakout - Brian Bulkowski - NVMe, Storage Class Memory and O...
IMC Summit 2016 Breakout - Brian Bulkowski - NVMe, Storage Class Memory and O...IMC Summit 2016 Breakout - Brian Bulkowski - NVMe, Storage Class Memory and O...
IMC Summit 2016 Breakout - Brian Bulkowski - NVMe, Storage Class Memory and O...
 
IMC Summit 2016 Breakout - Yanping Wang - Non-volatile Generic Object Program...
IMC Summit 2016 Breakout - Yanping Wang - Non-volatile Generic Object Program...IMC Summit 2016 Breakout - Yanping Wang - Non-volatile Generic Object Program...
IMC Summit 2016 Breakout - Yanping Wang - Non-volatile Generic Object Program...
 
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
IMC Summit 2016 Breakout - Andy Pavlo - What Non-Volatile Memory Means for th...
 
IMC Summit 2016 Breakout - Gordon Patrick - Developments in Persistent Memory
IMC Summit 2016 Breakout - Gordon Patrick - Developments in Persistent MemoryIMC Summit 2016 Breakout - Gordon Patrick - Developments in Persistent Memory
IMC Summit 2016 Breakout - Gordon Patrick - Developments in Persistent Memory
 
IMC Summit 2016 Breakout - Girish Kathalagiri - Decision Making with MLLIB, S...
IMC Summit 2016 Breakout - Girish Kathalagiri - Decision Making with MLLIB, S...IMC Summit 2016 Breakout - Girish Kathalagiri - Decision Making with MLLIB, S...
IMC Summit 2016 Breakout - Girish Kathalagiri - Decision Making with MLLIB, S...
 
IMC Summit 2016 Breakout - Steve Wikes - Making IMC Enterprise Grade
IMC Summit 2016 Breakout - Steve Wikes - Making IMC Enterprise GradeIMC Summit 2016 Breakout - Steve Wikes - Making IMC Enterprise Grade
IMC Summit 2016 Breakout - Steve Wikes - Making IMC Enterprise Grade
 
IMC Summit 2016 Breakout - Noah Arliss - The Truth: How to Test Your Distribu...
IMC Summit 2016 Breakout - Noah Arliss - The Truth: How to Test Your Distribu...IMC Summit 2016 Breakout - Noah Arliss - The Truth: How to Test Your Distribu...
IMC Summit 2016 Breakout - Noah Arliss - The Truth: How to Test Your Distribu...
 
IMC Summit 2016 Breakout - Girish Mutreja - Extreme Transaction Processing in...
IMC Summit 2016 Breakout - Girish Mutreja - Extreme Transaction Processing in...IMC Summit 2016 Breakout - Girish Mutreja - Extreme Transaction Processing in...
IMC Summit 2016 Breakout - Girish Mutreja - Extreme Transaction Processing in...
 
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
IMC Summit 2016 Breakout - Greg Luck - How to Speed Up Your Application Using...
 
IMC Summit 2016 Breakout - Pandurang Naik - Demystifying In-Memory Data Grid,...
IMC Summit 2016 Breakout - Pandurang Naik - Demystifying In-Memory Data Grid,...IMC Summit 2016 Breakout - Pandurang Naik - Demystifying In-Memory Data Grid,...
IMC Summit 2016 Breakout - Pandurang Naik - Demystifying In-Memory Data Grid,...
 

Recently uploaded

Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
StarCompliance.io
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
ewymefz
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
yhkoc
 
Computer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage sComputer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage s
MAQIB18
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
ukgaet
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
ewymefz
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
vcaxypu
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
enxupq
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
enxupq
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
benishzehra469
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
ArpitMalhotra16
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
ocavb
 

Recently uploaded (20)

Investigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_CrimesInvestigate & Recover / StarCompliance.io / Crypto_Crimes
Investigate & Recover / StarCompliance.io / Crypto_Crimes
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
 
Using PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDBUsing PDB Relocation to Move a Single PDB to Another Existing CDB
Using PDB Relocation to Move a Single PDB to Another Existing CDB
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
Computer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage sComputer Presentation.pptx ecommerce advantage s
Computer Presentation.pptx ecommerce advantage s
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .社内勉強会資料_LLM Agents                              .
社内勉強会資料_LLM Agents                              .
 
一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单一比一原版(NYU毕业证)纽约大学毕业证成绩单
一比一原版(NYU毕业证)纽约大学毕业证成绩单
 
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
 
Business update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMIBusiness update Q1 2024 Lar España Real Estate SOCIMI
Business update Q1 2024 Lar España Real Estate SOCIMI
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
 
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPsWebinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
 
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
一比一原版(ArtEZ毕业证)ArtEZ艺术学院毕业证成绩单
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单一比一原版(YU毕业证)约克大学毕业证成绩单
一比一原版(YU毕业证)约克大学毕业证成绩单
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
Empowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptxEmpowering Data Analytics Ecosystem.pptx
Empowering Data Analytics Ecosystem.pptx
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单一比一原版(TWU毕业证)西三一大学毕业证成绩单
一比一原版(TWU毕业证)西三一大学毕业证成绩单
 

IMC Summit 2016 Breakout - Aleksandar Seovic - The Illusion of Statelessness

  • 1. THE ILLUSION OF STATELESSNESS ALEKSANDAR SEOVIC Architect, Oracle Coherence See all the presentations from the In-Memory Computing Summit at http://imcsummit.org
  • 3. STUPID SHIT YOU CAN FIND ON THE WEB, TAKE 1 Bottom line: Stateless apps are ideal. Server-side database writes are your enemy. If you must save state, save it on the client. Use cookies and Ajax where appropriate. If you follow this rule, you will multiply your scalability.
  • 4. STUPID S#!T YOU CAN FIND ON THE WEB, TAKE 1 Bottom line: Stateless apps are ideal. Server-side database writes are your enemy. If you must save state, save it on the client. Use cookies and Ajax where appropriate. If you follow this rule, you will multiply your scalability.
  • 5. STUPID SHIT YOU CAN FIND ON THE WEB, TAKE 1 Bottom line: Stateless apps are ideal. Server-side database writes are your enemy. If you must save state, save it on the client. Use cookies and Ajax where appropriate. If you follow this rule, you will multiply your scalability.
  • 6. STUPID SHIT YOU CAN FIND ON THE WEB, TAKE 2 Services should be stateless. One benefit that you get from this is scalability. You can move expensive operations to a cluster of dedicated machines and it does not matter which one responds to a particular request since all of them are independent.
  • 7. STUPID S#!T YOU CAN FIND ON THE WEB, TAKE 2 Services should be stateless. One benefit that you get from this is scalability. You can move expensive operations to a cluster of dedicated machines and it does not matter which one responds to a particular request since all of them are independent.
  • 8. STUPID SHIT YOU CAN FIND ON THE WEB, TAKE 2 Services should be stateless. One benefit that you get from this is scalability. You can move expensive operations to a cluster of dedicated machines and it does not matter which one responds to a particular request since all of them are independent.
  • 9. AND FINALLY SOMEONE WITH A SENSE OF HUMOR… http://whatis.techtarget.com/definition/stateless
  • 10. AND FINALLY SOMEONE WITH A SENSE OF HUMOR… http://whatis.techtarget.com/definition/stateless
  • 11. AND FINALLY SOMEONE WITH A SENSE OF HUMOR… http://whatis.techtarget.com/definition/stateless
  • 12. FACT #1 HTTP protocol is stateless
  • 13. FACT #2 But your RESTful service is not
  • 14. AN EXAMPLE OF A TRULY STATELESS SERVICE @Path("calc") public class Calculator { @GET @Path("add") public int add(@QueryParam("x") int x, @QueryParam("y") int y) { return x + y; } }
  • 15. AN EXAMPLE OF A “STATELESS” SERVICE @Path("cart") public class CartService { @POST public Response addItem( @CookieParam("user.id") String userId, @FormParam("sku") String sku, @FormParam("price") BigDecimal price) { Cart cart = cartDao.getCartForUser(userId); cart.add(sku, price, 1); cartDao.save(cart); return Response.ok().build(); } @Inject private CartDao cartDao; }
  • 17. (REALLY) LIVE DEMO NEED A FEW VOLUNTEERS…
  • 18. FACT #3 “Stateless” services scale only as good as the state management layer they depend on
  • 19. BIG QUESTION So how do we really build scalable services and applications then?
  • 20. RULE #1 Separate state management and durability aspects. Manage state in memory, using technology that allows you to scale.
  • 24. EXAMPLE: ON DISK DURABILITY
  • 26. RULE #2 Don’t move data unless you absolutely have to. Send operations to the data instead.
  • 27. AN EXAMPLE: NEAR CACHING
  • 28. AN EXAMPLE: JAVA 8 LAMBDAS @Path("cart") public class CartService { @POST public Response addItem( @CookieParam("user.id") String userId, @FormParam("sku") String sku, @FormParam("price") BigDecimal price) { cartDao.process(userId, cart -> cart.add(sku, price, 1)); return Response.ok().build(); } @Inject private CartDao cartDao; }
  • 29. AN EXAMPLE: COHERENCE 12.2.1 DISTRIBUTED LAMBDAS public <R> R process(String userId, Remote.Function<Cart, R> cartFunction) { return carts.invoke(userId, entry -> { Cart cart = entry.getValue(); R result = cartFunction.apply(cart); entry.setValue(cart); return result; }); }
  • 30. RULE #3 Do whatever you can asynchronously
  • 31. AN EXAMPLE: AT THE ARCHITECTURAL LEVEL Is REST truly the best?
  • 32. AN EXAMPLE: JAVA 8 CompletableFuture // synchronous cache.put(1, "Aleks"); // asynchronous cache.async().put(1, "Aleks"); // synchronous System.out.println("Name: " + cache.get(1)); // asynchronous cache.async().get(1) .thenAccept(name -> System.out.println("Name: " + name));
  • 33. AN EXAMPLE: REACTIVE EXTENSIONS // reactive Observable<Void> observable = rx(cache).put(1, "Aleks"); rx(cache).get(1) .subscribe(name -> System.out.println("Name: " + name)); https://github.com/coherence-community/coherence- rx CoherenceRx
  • 34. RULE #4 Model complex processes as finite state machines, and use events to trigger state transitions
  • 35. AN EXAMPLE: ORDER PROCESSING
  • 36. RULE #5 Don’t use global locks, counters or other stupid shit that prevents you from scaling out.
  • 37. EXAMPLES (OF WHAT NOT TO DO)
  • 38. EXAMPLES (OF WHAT NOT TO DO)
  • 39. EXAMPLES (OF WHAT NOT TO DO)
  • 41. Q & A THANK YOU!
  • 42. Q & A THANK YOU!