Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Frank Stratton - Smart services & smart clients: How micro-services change the way you build and deploy code.

Frank Stratton - Smart services & smart clients: How micro-services change the way you build and deploy code.

At Runscope we've standardized the idea of small independent "smart" services that can be quickly built, deployed, and scaled. This talk examines lessons learned from writing these services as well as patterns found in other platforms. We present a detailed look at the code that allow us to build dozens of services, serving billions of requests, while deploying to our cluster over 20 times a day.

https://us.pycon.org/2015/schedule/presentation/337/

PyCon 2015

April 18, 2015
Tweet

More Decks by PyCon 2015

Other Decks in Programming

Transcript

  1. Smart Services & Smart Clients How microservices change the way

    you build and deploy code Frank Stratton
 Co-founder/CTO @FrankRStratton Runscope
  2. 0 000,000 000,000 000,000 000,000 000,000 May 2013 Sep Jan

    May Sep Jan 2015 Scaling the infrastructure Scaling the team
  3. if ENVIRONMENT == “local”: url = “http://localhost:5000/teams” elif ENVIRONMENT ==

    “test”: url = “http://test001.runscope.com/teams” elif ENVIRONMENT == “prod”: url = “http://host003.runscope.com/teams” Dashboard Identity get_teams()
  4. Smart Client Atlas Sidecar Runs HAProxy on each host. Reads

    cluster state from atlas. Watches for changes to services and updates the local configuration. host001 host002 host003
  5. haproxy.cfg frontend http-in bind *:4000 mode http acl host_api hdr(runscope-service)

    -i api acl host_billing hdr(runscope-service) -i billing acl host_mission-control hdr(runscope-service) -i mission-control acl host_elasticsearch hdr(runscope-service) -i elasticsearch use_backend api-backend if host_api use_backend billing-backend if host_billing use_backend mission-control-backend if host_mission-control use_backend elasticsearch-backend if host_elasticsearch
  6. Smart Service Various additions to the flask app object from

    flask import current_app current_app.realm current_app.redis current_app.database current_app.api
  7. $> generate-service my-awesome-service Creating a service skeleton with this configuration:

    Service name: my-awesome-service Destination directory: ~/runscope/my-awesome-service Python package name: my_awesome_service HTTP port: 5004 1. Generating files in ~/runscope/my-awesome-service 2. Initializing Git repository in ~/runscope/my-awesome-service 3. Creating virtualenv my-awesome-service 4. Installing Python prerequisites (requirements.txt and setup.py) All done! my-awesome-service source code can be found in ~/runscope/my-awesome-service Smart Service Auto Generate Service Skeletons
  8. Dashboard Traffic Gateway API And exposes an API for that

    data. Identity GET /teams/<id> PUT /teams/<id> GET /buckets ...
  9. 0 10 20 30 40 50 Jun 2014 Jul Aug

    Sep Oct Nov Dec Jan Feb Mar 2015 Deploys per day
  10. 0 10 20 30 40 50 Jun 2014 Jul Aug

    Sep Oct Nov Dec Jan Feb Mar 2015 Deploys per day
  11. Smart Services & Smart Clients How microservices change the way

    you build and deploy code Frank Stratton
 @FrankRStratton Runscope