First steps into developing an application as a suite of small services, and analysis of tools and architecture approaches to be used.
Topics covered:
1) What is a micro service architecture
2)Advantages in code procedures, team dynamics and scaling
3) How container services such as docker assist in its implementation
4) How to deploy code in a micro services architecture
5) Container Management tools and resource efficiency (mesos, kubernetes, aws container service)
6) Scaling up
By PeoplePerHour team
presented by CTO Spyros Lambrinidis & Senior DevOps Panagiotis Moustafellos @ Docker Athens Meetup 18/02/2015
Strategies for Landing an Oracle DBA Job as a Fresher
Â
introduction to micro services
1. Micro Services
Intro & implementation of a microservices
architecture
Docker Athens Spyros Lambrinidis @slambrinidis CTO
18 Feb 2014 Panagiotis Moustafellos @pmoust DevOps
2. What is a MicroService
âapproach to developing a single application as
a suite of small servicesâ
âdesigning software applications as suites of
independently deployable servicesâ
4. What is a MicroService
â Each service is loosely coupled /
independently deployable
â Changes made only to this service
â Each service has a bounded context
â Service should not know about surrounding service
(domain driven design)
5. Characteristics
â Services
â Products vs Projects
â Smart endpoints / dumb pipes
â Decentralized governance
â Decentralised data management
â Automation
â Design for failure
â Evolutionary design
6. Simple Blog Example
ELB
WebServer / FE
WebServer / FE
Comments
Service
Pages
Service
Posts
Service
Redis
MySql
MySql
Mongo
Redis
SOLR
7. Advantages
â Small code base / easier to test / maintain
â Easy to scale - clone
â Easy to throw away
â Easy to deploy and track errors
â Freedom to switch tech stack
â Maximise team agility
â Maximise resource utilisation
8. Disadvantages
â Devops challenge on multiple fronts
â Complexity in messaging and front end
â Most container technologies still new
â Freedom of tech stack not always good
news (for the future and for the CTO)
9. Micro Service and agility
â Modern agile practice can not ignore tech
â No modern tech = no absolute agility
â Micro services enable agility in a special way
â Enforce team creation
â Enforce faster deployments / better & easier tests
â CI / CD
â Easier communication flow methods (APIs)
â Each service = small scale product
10. Container Technology in micros
â Containers assist micro architecture in
â Visualising services
â Building / sharing services between coders
â Deploying services
â Utilising server resources to run containers
irrespective of underlying tech
â Popular container technologies
â Docker
â Rocket
11. Container Management
â Used to maintain and utilize containers /
services
â Make sure all services up and running
â Make sure server utilisation is maxed out
â Popular container management technologies
â CoreOS fleet
â Docker-machine
â Mesos
â Kubernetes
â AWS ECS / Google Container Engine
12. PPH Specifics
â Architecture history
â 2008 shared server â outsourced code â raw php
â 2010 more servers on peer1 and standalone mysql
â 2010 move to aws
â 2011 move to yii framework (not 100% complete)
â Multiple features and optimisation since then
â 2014 â supertasker.com launch
â Present
â Monolithic app
â Multiple db tech (sql, dynamo, mongo, memcache)
â Search through SOLR
â Traffic on supertasker.com
13. PPH Challenges
â Constantly Growing load (data + traffic)
â 160GB db
â 1300 rpm avg
â 35k uniques / day (55k sessions)
â Code complexity from multiple features
â Usage of yii v1.6 â difficult to change. Not exciting for
devs to work on it
â Code tightly coupled in many ways
â More products evolving and needing similar features â
supertasker.com
14. PPH Future
â Minimise core db - micros use their own
â Ability to scale to amazing level - scale out
â design to clone things (clone dbs / web servers)
â design to split things (one core vs many small ones)
â design to split similar things (shard / partition)
â Absolute resource utilisation
â Devs playground (use desired tech â within limits)
15. PPH Future
â Utilisation of communities through container sharing â
no need to share apps
â Service sharing between products
â Fully tested / API enabled services
â Gradually decrease power or core db and machines
â never reach maximum of scaliong up ability
16. PPH Micro Internals
â Container technology
â Docker
â Docker-compose
â Preferred micro language
â Php using yii v2 which is REST API enabled
â REST API
â Communication only through well defined APIs
â Full tested Services
â Each service to have full test coverage (unit & integration & contract)
17. PPH Micro Internals
â Data
â Each service to be tied to its own data
â Container Management
â CoreOS fleet
â Deployment
â CI tool
â shippable
18. Workflow: PPH Metrics
â planning the ecosystem
â keeping it simple
â describing the infrastructure plan under version control
â describing the API
â opting for identical D-S-P environments
â enforcing testing (make everything fail)
â deploying seamlessly (as possible)
â applying Continuous Integration & Continuous Delivery
20. PPH Metrics: defining an API
â Lots of tools (Swagger, RAML, etc)
â Well defined entities - check out schema.org
â Discussion amongst dev team for internal API usage
â Join Athens API Meetup :)
We were lazy - no excuses - moving on
21. PPH Metrics: KISS
â Single node definition
â Single scaling up/down strategy
â Platform agnostic (if possible)
â Human readable Configuration Management and IaC
â DevOps friendly (bridge the gap between Dev & Ops)
â API matters - Preferred Stack does not (or does it?)
â Bring up dev environment in seconds
23. PPH Metrics: Terraform
Why Terraform?
â Ops make mistakes
â Many environments, many resources, too much room for error, too little time for documenting changes and
current state
â Awesome human readable DSL
â Easy to maintain infrastructure state
â Multiple providers (we just needed AWS)
â Developers understand it
â Still very fresh, but well tested
â Created by Hashicorp
Version 0.3.7 meets our needs
We made small contributions that we needed to have upstream
24. Terraform DSL - defining an AWS autoscaling group behind a Load Balancer
25. PPH Metrics: CoreOS
Why CoreOS?
â Built with application containers in mind
â Built for scale
â Fleet - manages nodes and services in a cluster
â Etcd - distributed key-value store
â [Unit] - [Service] - [Timer]
â fleetctl - the cli tool to manage Fleet
â etcdctl - the cli tool to manage Etcd
27. PPH Metrics: Fleet + services
~ export FLEETCTL_ENDPOINT=http://10.30.2.234:4001
~ fleetctl list-machines
MACHINE IP METADATA
66cc918ae936440b896d201ee47b3877 10.30.2.234 role=microservices
bf78eab69d3f4c6f9310c971fd95fd4d 10.30.1.68 role=microservices
~ fleetctl start metrics.service
~ fleetctl list-units -l
UNIT MACHINE ACTIVE SUB
metrics.service 66cc918ae936440b896d201ee47b3877/10.30.2.234 active running
metrics.service bf78eab69d3f4c6f9310c971fd95fd4d/10.30.1.68 active running
28. PPH Metrics: etcd
Used for service discovery and generating configuration files (via confd or other methods)
~ etcdctl ls --recursive /
/microservices
/microservices/metrics/10.30.2.234:6000
/microservices/metrics/10.30.1.68:6000
/microservices/metrics/version/ffa2eeb4
/microservices/metrics/db/host/metrics.db.peopleperhour.com
/microservices/metrics/db/name/metrics
/microservices/metrics/db/user/awsdbuser
/microservices/metrics/db/pass/youwish
/microservices/metrics/aws/access_key/KEY
/microservices/metrics/aws/secret_key/SECRET_KEY
/microservices/metrics/google/adwords/clientId/CLIENT_ID
âŠ...
29. PPH Metrics: Keeping envs identical
The Stack
â MySQL
â Nginx
â PHP (in FastCGI)
â Memcached
â Metrics (our Yii2 framework app (with its dependencies))
In Staging and Production environments most of the stack is out of container scope
MySQL -> AWS RDS HTTP LoadBalancing -> AWS ELB Memcached - AWS ElasticCache
Etcd holds their endpoints and connection credentials
How do we link all these in a Development environment (and remain sane)?
30. PPH Metrics: docker-compose
Fast, isolated development environments using Docker.
Simple YAML syntax to link containers, container volumes, expose ports & link hosts.
31. â Deployment (strive for seamless updates)
â Continuous Integration
â Continuous Delivery
TBD in an upcoming Docker Athens Meetup
PPH Metrics: Ship it!