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

Building microservices step by step and deploy ...

Building microservices step by step and deploy in cloud run

Building microservices step by step and deploy in Cloud Run

Juan Guillermo Gómez Torres

December 07, 2019
Tweet

More Decks by Juan Guillermo Gómez Torres

Other Decks in Programming

Transcript

  1. Juan Guillermo Gómez • Co-Leader y Co-Founder del GDG Cali.

    • Founder DevHack. • Tech Lead Wordbox • Consultant and advisor on software architecture, cloud computing and software development. • Experience in several languages and platforms. (C, C#, Java, NodeJS, android, GCP, Firebase). • Google Developer Expert GCP & Firebase • BS in System Engineering and a MS in Software Engineering. • @jggomez
  2. Where the microservices come from? ❖ Modular Programming. ❖ POO

    ❖ RPC. ❖ EAI. ❖ AOP. ❖ Web Services. ❖ SOA
  3. Modeling Microservices ❖ Model services around the business domain. ❖

    Model services around quality attributes. ❖ Model services around cost
  4. Microservices Description with Open API 3 OpenAPI Specification (formerly Swagger

    Specification) is an API description format for REST APIs. An OpenAPI file allows you to describe your entire API, including: ❖ Available endpoints (/users) and operations on each endpoint (GET /users, POST /users) ❖ Operation parameters Input and output for each operation ❖ Authentication methods ❖ Contact information, license, terms of use and other information. ❖ API specifications can be written in YAML or JSON. The format is easy to learn and readable to both humans and machines.
  5. SERVERLESS ➢ Serverless architectures are application designs that incorporate third-party

    “Backend as a Service” (BaaS) services, and/or that include custom code run in managed, ephemeral containers on a “Functions as a Service” (FaaS) platform. ➢ Serverless architectures may benefit from significantly reduced operational cost, complexity, and engineering lead time, at a cost of increased reliance on vendor dependencies and comparatively immature supporting services. https://martinfowler.com/articles/serverless.html
  6. Cloud Run ➢ Cloud Run is a managed compute platform

    that automatically scales your stateless containers. Cloud Run is serverless: it abstracts away all infrastructure management, so you can focus on what matters most — building great applications. ➢ Run your containers in fully managed Cloud Run, or on Cloud Run for Anthos. Anthos supports GKE on Google Cloud, on-premises and multi-cloud environments. Cloud Run is built from Knative, ensuring that your applications are built on an open standard.
  7. Cloud Run - Deploy ❖ gcloud config set project PROJECT-ID

    ❖ gcloud builds submit --tag gcr.io/PROJECT-ID/accountservice ❖ gcloud beta run deploy --image gcr.io/PROJECT-ID/accountservice --platform managed
  8. Caching Microservices ❖ Use a memory repository for instance REDIS.

    ❖ Keep the data in the cache when it doesn’t change. ❖ if another component changes the data, the cache must be deleted. Queues can be the solution. ❖ Cloud run doesn’t support memory store but the cloud functions support memory store
  9. Security in the Microservices ❖ Consider implementing authentication at API

    Gateway level with widely-used API security standards such as OAuth2 and OpenID Connect. ❖ Create a API secret for app. ❖ Security channels ❖ JWT http://kasunpanorama.blogspot.com/2015/11/microservices-in-practice.html
  10. Best Practices Microservices ❖ Domain Driven Design. ❖ Decentralized Data

    Management ❖ Smart Endpoints and dump pipes ❖ Asynchronous Communication ❖ Avoid Coupling between Services ❖ Decentralize Development ❖ Monitoring Microservices
  11. Best Practices Microservices ❖ Keep domain knowledge out of the

    gateway ❖ Token-based Authentication ❖ Event Driven Nature ❖ Fault Tolerance. (circuit-breaking, bulkhead, retries, timeouts, fail fast, failover caching, rate limiters, load shedders) ❖ Product Engineering
  12. REFERENCES ❖ Building Microservices. Book. Sam Newman ❖ https://martinfowler.com/articles/microservices.html ❖

    https://martinfowler.com/articles/serverless.html ❖ https://cloud.google.com/run/ ❖ https://medium.com/weareservian/3-best-features-of-google-cloud-run-546e367242ea ❖ https://medium.com/platform-engineer/microservices-design-guide-eca0b799a7e8 ❖ https://blog.risingstack.com/designing-microservices-architecture-for-failure/ ❖ http://kasunpanorama.blogspot.com/2015/11/microservices-in-practice.html