What Are Microservices Really All About? (And When Not To Use It)

ByteByteGo
11 Oct 202204:45

Summary

TLDRThe video script delves into microservices architecture, highlighting its benefits for large teams in building scalable applications with loosely coupled services. It explains the independent deployment, scalability, and communication methods of microservices, such as RPC and event streaming. The script also addresses challenges like maintaining data integrity and the necessity of components like API gateways and service registries. It concludes by discussing the suitability of microservices for large teams and the importance of well-defined interfaces for potential future adoption by startups.

Takeaways

  • šŸ”Œ Microservices architecture allows for the development of scalable applications through many loosely coupled services.
  • šŸ›  Each microservice in the architecture has a dedicated function, such as shopping cart, billing, or user profile management, and is considered a separate domain.
  • šŸ”— Microservices communicate through well-defined interfaces with small surface areas to limit the impact of failures and defects.
  • šŸš€ They can use remote procedure calls (RPC), event streaming, or message brokers for communication, each with its advantages and drawbacks.
  • šŸš¦ Microservices can be independently deployed, providing operators with confidence and flexibility in frequent deployments.
  • āš–ļø The architecture offers operational flexibility to scale individual services independently, which is highly valuable.
  • šŸ”’ Well-architected microservices practice strong information hiding, often involving breaking up monolithic databases into logical components.
  • šŸ—ƒļø One challenge with microservices is maintaining data integrity without the traditional database foreign key relationships and referential integrity.
  • šŸšŖ A key component of microservices architecture is the API gateway, which routes incoming requests to the appropriate microservices after authentication.
  • šŸ“ The API gateway uses a service registry and discovery service to locate and route to microservices, which must register and discover each other's locations.
  • šŸ›‘ Additional components like monitoring, alerting, and DevOps tools are essential for the successful implementation of microservices architecture.
  • šŸ’” Microservices architecture is most beneficial for large teams, enabling team independence and fast movement with contained failure impacts, but may not be suitable for small startups due to the overhead involved.

Q & A

  • What is the main advantage of using microservices architecture for large teams?

    -Microservices architecture allows large teams to build scalable applications by decomposing them into many loosely coupled services, which enhances team independence and allows each team to work on their respective domains with agility and reduced risk of widespread failures.

  • How are microservices defined in the context of an application?

    -Microservices are individual components of an application that handle dedicated functions, such as shopping cart, billing, user profile, and push notifications. They operate independently and communicate with each other through well-defined interfaces.

  • What is the significance of having small surface areas in the interfaces of microservices?

    -Small surface areas in microservices interfaces limit the impact of failures and defects, making it easier to understand and manage the interactions between services within the larger application context.

  • How do microservices communicate with each other?

    -Microservices communicate through a combination of remote procedure calls (RPC), event streaming, or message brokers, each offering different trade-offs in terms of response time and isolation.

  • What is the impact of using RPC for communication between microservices?

    -RPC, such as gRPC, provides faster response times but has a larger blast radius, meaning if a service goes down, it can have a more significant impact on other services.

  • Why is it beneficial for microservices to be independently deployable?

    -Independent deployment of microservices allows for more frequent and confident releases, as each service is smaller and has a limited impact area, reducing the risk associated with deployment.

  • What operational flexibility does microservices architecture provide?

    -Microservices architecture offers the flexibility to scale individual services independently based on demand, which is invaluable for optimizing resource usage and application performance.

  • Why is strong information hiding important in well-architected microservices?

    -Strong information hiding in microservices helps to encapsulate the logical components within each service, promoting better modularity and reducing dependencies between services.

  • What are the implications of breaking up a monolithic database into logical components for microservices?

    -Breaking up a monolithic database into logical components for microservices means that foreign key relationships and referential integrity can no longer be enforced at the database level, shifting the responsibility of maintaining data integrity to the application layer.

  • What role does an API gateway play in a microservices architecture?

    -An API gateway in a microservices architecture handles incoming requests, routes them to the appropriate microservices, and relies on an identity provider for authentication and authorization of requests.

  • Why is a service registry and discovery service important for microservices?

    -A service registry and discovery service is crucial for microservices to locate and communicate with each other, allowing the API gateway to route requests and services to discover each other's locations.

  • When is microservices architecture most suitable for implementation?

    -Microservices architecture is most suitable for large teams with the resources to manage its complexity. It enables team independence and rapid development but may not be ideal for small startups due to the overhead involved.

  • What advice is given to startups considering the adoption of microservices architecture?

    -Startups are advised to design each function in the application with a well-defined interface, making it easier to migrate to a microservices architecture if the business and team grow and it becomes more appropriate.

Outlines

00:00

šŸ›  Microservices Architecture Overview

The script introduces microservices architecture as a scalable solution for large teams to build applications composed of many loosely coupled services. It defines microservices as individual, function-specific components within an application, such as shopping cart, billing, and user profiles, which communicate through well-defined interfaces to limit failure impact. The benefits include ease of reasoning, independent deployment, and the ability to scale services individually. However, it also highlights the challenges of maintaining data integrity without traditional database relationships.

Mindmap

Keywords

šŸ’”Microservices architecture

Microservices architecture is a software design pattern where an application is composed of small, independent services that communicate with each other. It is central to the video's theme as it enables scalability and flexibility in large-scale applications. The script uses the concept to discuss how large teams can build applications composed of many loosely coupled services, each handling a specific function.

šŸ’”Loosely coupled services

Loosely coupled services are components of a system that interact with each other but are not tightly bound. This concept is key to the script's discussion of microservices, as it allows for easier maintenance and updates of individual services without affecting the entire system, as seen in the example of services like shopping cart, billing, and user profile.

šŸ’”Dedicated function

A dedicated function refers to a specific task or responsibility within a system. In the context of the video, each microservice has a dedicated function, which contributes to the overall functionality of the application. This is exemplified by the script's mention of services like push notifications and user profiles, each serving a distinct purpose.

šŸ’”Well-defined interfaces

Well-defined interfaces in the script refer to the clear and specific points of interaction between microservices. They are crucial for limiting the impact of failures and ensuring that services can communicate effectively. The script mentions that these interfaces help in making each service easier to understand within the larger application context.

šŸ’”Remote Procedure Calls (RPC)

Remote Procedure Calls (RPC) is a protocol used by microservices to communicate with each other. The script discusses RPC, such as gRPC, as a method that provides faster response times but may have a larger impact on other services if one service fails, illustrating the trade-off between speed and fault isolation.

šŸ’”Event streaming

Event streaming is a method of communication between microservices where events are pushed to a stream and processed asynchronously. The script contrasts event streaming with RPC, noting that while it offers better isolation between services, it may take longer to process, which is a key consideration in microservices design.

šŸ’”Independent deployment

Independent deployment means that each microservice can be deployed separately from the others. The script highlights this as a benefit of microservices architecture, allowing for more frequent and less risky updates to individual services without affecting the entire application.

šŸ’”Operational flexibility

Operational flexibility refers to the ability to manage and scale services independently based on demand. The script emphasizes this as a significant advantage of microservices, allowing for individual scaling of services to meet varying loads and requirements.

šŸ’”Strong information hiding

Strong information hiding is a principle where microservices keep their internal workings hidden from others, exposing only what is necessary. The script explains that this practice often involves breaking up monolithic databases into logical components that are kept within their respective microservices, enhancing modularity and security.

šŸ’”API gateway

An API gateway is a server that acts as an entry point into a system of microservices. The script describes the API gateway's role in handling incoming requests and routing them to the appropriate microservices, relying on a service registry and discovery service to locate the services.

šŸ’”Service registry and discovery

A service registry and discovery mechanism is used to keep track of microservices and their locations. The script explains that microservices register with this service to be discoverable, which is essential for the API gateway to route requests correctly.

šŸ’”DevOps toolings

DevOps toolings refer to the tools and practices used to enhance collaboration between development and operations teams. The script mentions these tools in the context of microservices architecture, where they are used for deployment, monitoring, and troubleshooting, supporting the continuous integration and delivery process.

Highlights

Microservices architecture allows large teams to build scalable applications composed of loosely coupled services.

Each microservice in a microservices architecture handles a dedicated function within the application, such as shopping cart, billing, or user profile.

Microservices communicate via well-defined interfaces with small surface areas to limit the impact of failures.

Remote procedure calls (RPC) like gRPC provide faster response times but have a larger blast radius when a service fails.

Event streaming offers better isolation between services but may have longer processing times.

Microservices can be independently deployed, providing peace of mind and confidence for frequent deployments.

The architecture allows for the independent scaling of individual microservices, offering operational flexibility.

Well-architected microservices practice strong information hiding, often involving the separation of monolithic databases into logical components.

Breaking up databases in microservices can eliminate foreign key relationships and shift the burden of maintaining data integrity to the application layer.

An API gateway is a key component in microservices architecture, handling incoming requests and routing them to relevant services.

The API gateway relies on an identity provider service for authentication and authorization of requests.

Service registry and discovery services are used by the API gateway to locate and route requests to microservices.

Other components like monitoring, alerting, and DevOps tooling are useful in a microservices architecture for deployment and troubleshooting.

Microservices architecture is cost-intensive and best suited for large teams, enabling team independence and fast movement with contained failure impact.

For startups, designing each function with a well-defined interface can make future migration to microservices architecture more manageable.

The overhead of implementing microservices architecture is significant and may not be suitable for small startups initially.

Resources such as books and a weekly newsletter on system design can provide further insights into microservices and other architectural patterns.

Transcripts

play00:08

Microservices architecture enables largeĀ  teams to build scalable applications thatĀ Ā 

play00:13

are composed of many loosely coupled services.

play00:16

What does a typical microservicesĀ  architecture look like?

play00:19

And when should we use it?

play00:21

Letā€™s take a look.

play00:23

Microservices are loosely coupled.

play00:25

Each service handles a dedicated functionĀ  inside a large-scale application.

play00:30

For example, shopping cart, billing, user profile,Ā Ā 

play00:34

push notifications can allĀ  be individual microservices.

play00:37

These functional areas areĀ  sometimes called domains.

play00:42

Microservices communicate with each other viaĀ  well-defined interfaces with small surface areas.

play00:48

The small surface areas limit theĀ  blast radius of failures and defects.

play00:53

It makes each service easier to reason aboutĀ  in the context of the entire application.

play01:00

Microservices talk to one another over aĀ  combination of remote procedure calls (RPC),Ā Ā 

play01:06

event streaming, or message brokers.

play01:09

RPC like gRPC provides fasterĀ  response, but the blast radius,Ā Ā 

play01:14

or the impact to other microservices, wouldĀ  be larger when the service was to go down.

play01:21

Event streaming provides better isolationĀ  between services but they take longer to process.

play01:27

Microservices can be independently deployed.

play01:30

Since each service is small, easier toĀ  reason about, and has a smaller blast radius,Ā Ā 

play01:36

this gives the operators peace ofĀ  mind and confidence to deploy often.

play01:41

Microservices provide more flexibility to scaleĀ  up individual microservices independently.

play01:47

The operational flexibility is invaluable.

play01:51

Well-architected microservicesĀ  practice strong information hiding.

play01:55

This often means breaking up a monolithicĀ  database into its logical components andĀ Ā 

play02:01

keeping each logical component well hiddenĀ  inside its corresponding microservice.

play02:06

By logical component, it could meanĀ  a separate schema within a databaseĀ Ā 

play02:11

cluster or an entirely separate physical database.

play02:14

This is an implementation detail.

play02:18

However, one big drawback of microservicesĀ  is the breaking up of the database.

play02:24

By breaking up a database into separateĀ  logical units, the database can no longerĀ Ā 

play02:29

maintain foreign key relationships and enforceĀ  referential integrity between these units.

play02:35

The burden of maintaining data integrityĀ  is now moved into the application layer.

play02:41

Letā€™s take a look at other criticalĀ  components required for a successfulĀ Ā 

play02:45

implementation of microservices architecture.

play02:49

A key component is an API gateway.Ā Ā 

play02:52

API gateway handles incoming requests andĀ  routes them to the relevant microservices.

play02:58

The API gateway relies on an identity providerĀ  service to handle the authentication and putĀ Ā 

play03:04

authorization of each requestĀ  coming through the API gateway.

play03:08

To locate the service toĀ  route an incoming request to,Ā Ā 

play03:11

the API gateway consults a serviceĀ  registry and discovery service.

play03:17

Microservices register with thisĀ  service registry and discover theĀ Ā 

play03:21

location of other microservicesĀ  through the discovery service.

play03:25

There are other useful componentsĀ  in a microservices architecture likeĀ Ā 

play03:29

monitoring and alerting, DevOps toolings forĀ  deployment, and troubleshooting, for example.

play03:35

Letā€™s wrap up by discussing whenĀ  to use microservices architecture.

play03:41

Microservices cost money to build and operate.

play03:44

It really only makes sense for large teams.

play03:47

For large teams, it enables team independence.

play03:50

Each domain, or function, can beĀ  independently maintained by a dedicated team.

play03:56

In a well-designed microservices architecture,Ā Ā 

play03:59

these independent teams can move fast, and theĀ  blast radius of failures is well-contained.

play04:05

Each service could be independentlyĀ  designed, deployed, and scaled.

play04:09

However, the overhead of a sound implementation isĀ Ā 

play04:13

so large that it is usually notĀ  a good fit for small startups.

play04:17

One advice for startups is to design each functionĀ  in the application with a well-defined interface.

play04:24

One day if the business and teamĀ  are growing fast that microservicesĀ Ā 

play04:28

architecture starts to make sense, itĀ  would be more manageable to migrate.

play04:34

If you would like to learn more about systemĀ  design, check out our books and weekly newsletter.

play04:38

Please subscribe if you learned something new.

play04:40

Thank you so much, and weā€™ll see you next time.

Rate This
ā˜…
ā˜…
ā˜…
ā˜…
ā˜…

5.0 / 5 (0 votes)

Related Tags
MicroservicesScalabilityArchitectureLoose CouplingRPCEvent StreamingAPI GatewayService RegistryDevOpsData IntegrityTeam Independence