Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.
Auto-scaling your API
Insights and Tips from the Zalando Team
JBCNConf 2015

Barcelona, Spain
Sean Patrick Floyd - @oldJav...
15 countries
3 fulfilment centers
15+ million active customers
2.2+ billion € revenue 2014
130+ million visits per month
8...
Our Scale
Based on https://flic.kr/p/bX5E4c
2 datacenters
thousands of production instances
serving 15 countries
Zalando stack
Credits to our colleague Kolja Wilcke
Credits to our colleague Kolja Wilcke
Credits to our colleague Kolja Wilcke
The Shop
Monolith
We call it “Jimmy”
http://blog.codinghorror.com/new-programming-jargon/
Thousands of Java classes, undocumented features
Business logic on all layers (including the database)
https://flic.kr/p/n...
https://flic.kr/p/tW4sus
It’s 2013…



Zalando wants to
sponsor hackathons…
We need a REST API!
Hackathon

API
First Step
Let’s create some REST-(ish) Spring
controllers inside our monolithic web
application
Deploy a couple of Jimmy ...
Pros
The infrastructure is already there!
A few days of coding and we’re all set
Cons
This “API” cannot be deployed independently
of Jimmy.
Jimmy is infested with business logic
everywhere.
New
Requirements
New Requirements
We needed this new API for our existing
frontends, also (very high traffic).
Some third-party apps also w...
Shop Public API
We decided to build a “real” API as a separate
standalone project.
Of course, there were some dependencies…
Data Sources
1.Catalog - SOLr
2.Stock - Memcached
3.Reviews - REST(-ish) API
4.Recommendations - RPC
5.Database - PostgreS...
All of them in the same data centers.
This should be no problem…
Tech
Company
Paradigm Shift
Until 2014
We’re a Fashion Company that has a lot 

of tech knowledge
2015
Suddenly we’re a Tech Company, p...
We established
5 principles
API FIRST
API First
Document and peer review your API in a
format like Swagger before writing a single
line of code.
Ideally, either...
REST
REST
Manipulate resources, don't call methods
Expose nouns, not verbs
Use HTTP verbs
GET, PUT, POST, DELETE, PATCH
SAAS
Identity Management
Our backend services don’t expose APIs yet
Company-wide IAM strategy is not ready yet
Can only expose ...
MICRO-
SERVICES
Microservices
We already have a Service-Oriented
Architecture
It was mostly SOAP, though…
And definitely not micro
CLOUD
Road to AWS
Some challenges ahead…
1. Backend services not available yet
2. SOLr also not available
3. We can’t just move ...
How we

did it
Challenges
Catalog and Stock datasources are latency critical
and they’re owned by different teams!
Can we solve that?
Step 1 - move critical datasources to AWS
“Move” Data Sources to AWS
We can’t just move them!
Jimmy also needs them in the data centers,
you insensitive clod!
Ok… w...
and then…?
Replicating Data Sources
SOLr has its own replication mechanism
over HTTP
memcached should be easy …
You wish!
Step 2 - Build memcached replication
Stock Relay
Memcached #1
Memcached #2
Memcached #3
Stock Relay(s)
SNS Topic
…
Datacenter
eu-central-1
Memcached ElasticCac...
and then…?
AWS SOLr Repeater
Datacenter Master
eu-central-1
eu-west-1
us-east-1
SOLr Slaves Shop Public APIRegion Repeater
SOLr Slave...
Autoscaling SOLr and API
http://www.docstoc.com/docs/109290533/Lucid-Imagination# by Erick Erickson
Region repeater
Slave ...
Scaling Limitations
Edited from https://flic.kr/p/zuBXM
Region repeater
Autoscaling Group
Slave #1
Slave #2
Slave #3
Slave...
Y U no scale!
S3 Bucket for Replication
Datacenter Master
eu-central-1
eu-west-1
us-east-1
SOLr Slaves Shop Public API
Master Repeater S...
I see…
“Onion layers” for Replication
• Start with a single repeater layer -
layer0.solr
• Setup a Route53 CNAME repeater
that li...
“Onion layers” for Replication
• Setup CloudWatch alarms for
relevant metrics in the repeater layer.
Give them some slack ...
“Onion layers” for Replication
• onion-layers creates a new ASG
layer. Calculates currentLayer =
currentLayer + 1
• The ne...
“Onion layers” for Replication
• After replication, the CNAME
repeater is updated to link to
layer<currentLayer>-repeater....
Yes. These tools will be open-sourced soon
Thank you for listening
Check out our blog https://tech.zalando.com
Our many open source products https://github.com/zalan...
Auto-scaling your API: Insights and Tips from the Zalando Team
Auto-scaling your API: Insights and Tips from the Zalando Team
Auto-scaling your API: Insights and Tips from the Zalando Team
Nächste SlideShare
Wird geladen in …5
×

Auto-scaling your API: Insights and Tips from the Zalando Team

4.612 Aufrufe

Veröffentlicht am

A presentation given by Zalando software engineers Sean Floyd and Luis Mineiro at the JBCNConf in Barcelona, Spain, June 2015. Zalando is Europe's largest online fashion platform, doing business in 15 countries with more than 15 million users. Visit tech.zalando.com for more information about Zalando's technology, open source projects and opportunities.

Veröffentlicht in: Technologie
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

Auto-scaling your API: Insights and Tips from the Zalando Team

  1. 1. Auto-scaling your API Insights and Tips from the Zalando Team JBCNConf 2015
 Barcelona, Spain Sean Patrick Floyd - @oldJavaGuy
 Luis Mineiro - @voidmaze
  2. 2. 15 countries 3 fulfilment centers 15+ million active customers 2.2+ billion € revenue 2014 130+ million visits per month 8.000+ employees ONE of EUROPE’S LARGEST ONLINE FASHION RETAILERS Visit us: tech.zalando.com Tech hubs in Berlin, Dublin, Dortmund and Helsinki
  3. 3. Our Scale Based on https://flic.kr/p/bX5E4c 2 datacenters thousands of production instances serving 15 countries
  4. 4. Zalando stack Credits to our colleague Kolja Wilcke
  5. 5. Credits to our colleague Kolja Wilcke
  6. 6. Credits to our colleague Kolja Wilcke
  7. 7. The Shop Monolith
  8. 8. We call it “Jimmy” http://blog.codinghorror.com/new-programming-jargon/
  9. 9. Thousands of Java classes, undocumented features Business logic on all layers (including the database) https://flic.kr/p/nBhvfy
  10. 10. https://flic.kr/p/tW4sus It’s 2013…
 
 Zalando wants to sponsor hackathons… We need a REST API!
  11. 11. Hackathon
 API
  12. 12. First Step Let’s create some REST-(ish) Spring controllers inside our monolithic web application Deploy a couple of Jimmy instances just to serve requests for this “API”
  13. 13. Pros The infrastructure is already there! A few days of coding and we’re all set
  14. 14. Cons This “API” cannot be deployed independently of Jimmy. Jimmy is infested with business logic everywhere.
  15. 15. New Requirements
  16. 16. New Requirements We needed this new API for our existing frontends, also (very high traffic). Some third-party apps also wanted to use this API as their backend.
  17. 17. Shop Public API We decided to build a “real” API as a separate standalone project. Of course, there were some dependencies…
  18. 18. Data Sources 1.Catalog - SOLr 2.Stock - Memcached 3.Reviews - REST(-ish) API 4.Recommendations - RPC 5.Database - PostgreSQL Shop Public API Catalog Stock Reviews Recommendations Database
  19. 19. All of them in the same data centers. This should be no problem…
  20. 20. Tech Company
  21. 21. Paradigm Shift Until 2014 We’re a Fashion Company that has a lot 
 of tech knowledge 2015 Suddenly we’re a Tech Company, providing “Fashion as a Service”
  22. 22. We established 5 principles
  23. 23. API FIRST
  24. 24. API First Document and peer review your API in a format like Swagger before writing a single line of code. Ideally, either generate either your server interfaces or your test data (or both) from the Swagger spec
  25. 25. REST
  26. 26. REST Manipulate resources, don't call methods Expose nouns, not verbs Use HTTP verbs GET, PUT, POST, DELETE, PATCH
  27. 27. SAAS
  28. 28. Identity Management Our backend services don’t expose APIs yet Company-wide IAM strategy is not ready yet Can only expose read-only features for now
  29. 29. MICRO- SERVICES
  30. 30. Microservices We already have a Service-Oriented Architecture It was mostly SOAP, though… And definitely not micro
  31. 31. CLOUD
  32. 32. Road to AWS Some challenges ahead… 1. Backend services not available yet 2. SOLr also not available 3. We can’t just move the databases there
  33. 33. How we
 did it
  34. 34. Challenges Catalog and Stock datasources are latency critical and they’re owned by different teams!
  35. 35. Can we solve that?
  36. 36. Step 1 - move critical datasources to AWS
  37. 37. “Move” Data Sources to AWS We can’t just move them! Jimmy also needs them in the data centers, you insensitive clod! Ok… we just replicate them.
  38. 38. and then…?
  39. 39. Replicating Data Sources SOLr has its own replication mechanism over HTTP memcached should be easy …
  40. 40. You wish!
  41. 41. Step 2 - Build memcached replication
  42. 42. Stock Relay Memcached #1 Memcached #2 Memcached #3 Stock Relay(s) SNS Topic … Datacenter eu-central-1 Memcached ElasticCacheStock Repeater(s) Shop Public APISQS Queue eu-west-1 Memcached ElasticCacheStock Repeater(s) Shop Public APISQS Queue us-east-1 Memcached ElasticCacheStock Repeater(s) Shop Public APISQS Queue SET / DELETE GET GET GET
  43. 43. and then…?
  44. 44. AWS SOLr Repeater Datacenter Master eu-central-1 eu-west-1 us-east-1 SOLr Slaves Shop Public APIRegion Repeater SOLr Slaves Shop Public APIAWS Master Repeater SOLr Slaves Shop Public APIRegion Repeater
  45. 45. Autoscaling SOLr and API http://www.docstoc.com/docs/109290533/Lucid-Imagination# by Erick Erickson Region repeater Slave #1 Autoscaling Group Slave #2 Slave n API Node #1 Autoscaling Group API Node #2 API Node n https://api.zalando.com
  46. 46. Scaling Limitations Edited from https://flic.kr/p/zuBXM Region repeater Autoscaling Group Slave #1 Slave #2 Slave #3 Slave #3 Slave #3 Slave #3 Slave #11 Slave #18 Slave #3 Slave #34Slave #3 Slave #3 Slave #59 Slave #3 Slave #3 Slave #123 Slave #3 Slave #3 Slave #3 Slave #3 Slave #3 Slave #325 Slave #3 Slave #3 Slave #3 Slave #3 Slave #42815
  47. 47. Y U no scale!
  48. 48. S3 Bucket for Replication Datacenter Master eu-central-1 eu-west-1 us-east-1 SOLr Slaves Shop Public API Master Repeater SOLr Slaves Shop Public API SOLr Slaves Shop Public API S3replicationS3replication
  49. 49. I see…
  50. 50. “Onion layers” for Replication • Start with a single repeater layer - layer0.solr • Setup a Route53 CNAME repeater that links to it - repeater.solr • Entire slave fleet in the ASG is always configured to replicate from repeater.solr CNAME repeater Slave #1 Autoscaling Group Slave #2 Slave n slave.solr layer0-repeater.solr
  51. 51. “Onion layers” for Replication • Setup CloudWatch alarms for relevant metrics in the repeater layer. Give them some slack space. • Configure it to send notifications to the onion-layers-topic. • Bring up your instance of onion- layers. CloudWatch CNAME repeater Slave #1 Autoscaling Group Slave #2 Slave n slave.solr layer0-repeater.solr
  52. 52. “Onion layers” for Replication • onion-layers creates a new ASG layer. Calculates currentLayer = currentLayer + 1 • The new layer starts replicating from layer<currentLayer-1>-repeater • Adds a new Route53 recordset layer<currentLayer>-repeater. CNAME repeater CloudWatch Autoscaling Group layer1-repeater.solr layer0-repeater.solr onion-layers Autoscaling Group slave.solr
  53. 53. “Onion layers” for Replication • After replication, the CNAME repeater is updated to link to layer<currentLayer>-repeater. • onion-layers acts on alarms for the connection between current layer and previous layer. • You can still have your own AS alarms for the connection between slaves and current layer. CNAME repeater CloudWatch Autoscaling Group layer1-repeater.solr layer0-repeater.solr Autoscaling Group slave.solr
  54. 54. Yes. These tools will be open-sourced soon
  55. 55. Thank you for listening Check out our blog https://tech.zalando.com Our many open source products https://github.com/zalando The STUPS stack https://stups.io Got more questions? You can reach us on twitter @ZalandoTech We’re hiring! Special thanks to Jessie Dude. No Continuum Transfunctioners were harmed during the production of these slides.

×