Skip to content

Latest commit

 

History

History
91 lines (69 loc) · 3.36 KB

microservices.md

File metadata and controls

91 lines (69 loc) · 3.36 KB

Microservices

TODO finish and refine this page

Run small services that do one thing well.

It is the services equivalent of the 50 year battle-test unix core utils philosophy.

These services communicate with each other via APIs, typically simple HTTPS Rest APIs.

However, while these smaller distributed services reduce monolithic code complexity by decoupling as much as possible, they introduce infrastructure complexity compared to monoliths.

The code of each service may be much simpler, but they simply shift the complexity to the infrastructure, high availability and especially monitoring and tracing what happens to requests as they traverse the many components through the stack.

Key Points

  • run smaller services
  • smaller footprint per service
  • results in more services, more stacks
  • easy to create + move independently by relying on standard TCP/IP networking
  • scales more easily as individual components
  • lower code complexity by splitting functionality
  • higher infrastructure complexity
    • especially monitoring & tracing

Challenges

  • Orchestration
  • Configuration Management
  • Data Persistence
  • Monitoring
    • Logging
    • Tracing

Microservices Stacks

Commonly used technologies in microservices stacks:

  • Docker
  • Kubernetes
  • Consul
    • Coordination & Discovery system used to find other service dependencies
    • Key-Value store used to store both config and templates, as single source of truth
  • ELK stack (logging)
  • Cloud services
  • Ansible (orchestration) - old - usually only used for VMs and not for modern containerized technologies

Best Practices

  • immutable services where possible
  • abstract out storage to specialist data services like RBDMS or NoSQL avoid state maintenance on apps
  • even Kubernetes components and Mesos masters run as Docker containers
  • service discovery (eg. Consul of Kubernetes internal DNS)
  • standardize containers or AWS AMIs for lower maintenance
  • CI/CD to manage deployments
  • logging - all services should log to json

Logging

  • Cloud logging services:
  • ELK stack:
    • LogStash => Elasticsearch => Kibana
    • all services should log to json
    • this avoids other services writing logs locally and allows for read-only filesystem immutable Docker containers

Misc Notes

  • Traffic routing via NginX + PowerDNS, backed by Consul
  • Registrator service, hooks in to Dockerdaemon and tells Consul when other services come alive or die
  • Docker mounts a directory with the config from Consul
  • 11 months from idea to production, bleeding edge but getting better
  • Developers can self-provision QA, key part of the process, DevOps only maintain the infrastructure