notes

Anti-Patterns

Table of content

Description

Antipattern - something that seems like a good idea when you begin, but leads you into trouble.

Data Driven Migration

  1. Migration monolithic data to dedicated databases along with microservices.
  2. We should treat data and data migration with care.
  3. It’s better to split application at first, and then after some time split data. Because it’s really hard, reasky and expensive to migrate data back, otherwise it’s really easy to split your application into microservices wrong way at the begining.
  4. Analysys
    1. Map services to existing data tables to identify ownership
    2. Identify data overlap and dependencies between services
    3. Develop functional migration plan for each service
    4. Develop separate data migration plan for each service.
    5. Implement migration in two steps: functional migration, then data migration.
  5. Goals
    1. Avoid frequent data migration
    2. Identify data sharing needs to help determine service granularity

All the World a Stage

  1. Placing too much focus on technology and infrastructure (staging iterations) and not enough on business functionality
  2. If we put a lot of effort on an infrastructure and forget to enhance buiseness functionality we will end up with good infrastructure and unhappy business. In most cases we don’t need full devops environment to introduce a couple of services, because when we have couple of services we could do most of the work manually.
  3. Analysis
    1. Identify the staging iterations in your iteration plan
    2. Identify dependencies between staging and functional iterations
    3. Identify opportunities for parallel staging tasks
  4. Goals
    1. Reduce staging iterations
    2. Deliver business functionality faster

Hop on the Bus

  1. Adding an integration hub to your microservices architecture. e.g. Apache Camel, Muel, Shuttle
  2. Disadvantages:
    • Creates coupling between microservices
    • Descreases performance
    • Increases complexity
    • Governance
    • Could kill deployment pipeline
    • Complicates development and testing
  3. Analysis
    1. Identify requests requiring transformation
    2. Identify requests requiring orchestration
    3. Identify requests that access third-party systems
    4. Analyze use of messaging microservices (Adapter, Gateway, Transform, Orchestrator)
  4. Goals
    1. Provide messaging capabilities without the use of an integration hub
    2. Favor choreography over orchestration

Timeout

  1. Using timeout values when waiting for a response from a remote service call
  2. We want to avoid cases when server successfully processed requests, but client got request timeout.
  3. To set correct timeout we could use: timeout = (max response time under load) * 2
  4. To handle correct timeout we should use circuit breaker. The best way to implement it is to monitor real user transactions.
  5. Reading
  6. Analysis
    • Document your strategy for reacting to server responsiveness
    • Identify opportunities for using the circuit breaker pattern
    • Externalize your timeout values through configuration properties or external data driven values
  7. Goal
    • Reduce the time to determine if a service is non-responsible
    • Avoid timing-out requests when the service has recovered

Reach in Reporting

  1. Pulling data from each microservice or its corresponding database for reporting purposes
  2. There are the following ways to implement reporting in microservices architecture
    • db pull - when we pull data from directly from databases of different microservices.
      • - bounded context
      • + timeliness
    • http pull - when we get data from different microservices using http requests
      • +- bounded context
      • - timeliness
    • batch pull - when we get data from different microservices at the specific period of time (every hour, nightly)
      • +- bounded context
      • +- timeliness
    • event push - we publish events what happened with every microservice, reports service handle and process these events
      • + bounded context
      • + timeliness
  3. Analysis
    • List your reporting requirements and the timeliness of reports
    • Can you maintain a separate reporting database or warehouse?
    • List the data required for reporting from each service
  4. Goals
    • Maintain a strong bounded context for each service and its corresponding data
    • Provide timely data for reporting

I was taught to share

  1. Sharing too many modules and custom libraries between microservices.
  2. If we have too many modules it’s really tricky to stay them up to date.
  3. It’s better to not create modules like common, because this module will be changed very fast and it would be really hard to follow. It’s much better to have multiple small modules. The finer the granuallity of the modules the easier to change it.
  4. Sometimes we can just replicate (copy/past) some code between microservices.
    • the fewer dependencies between microservices the easier is to change, test and deploy them
    • this method is better to use for almost mutable modules
  5. If we have some shared library between 2 or 3 services, and that shared library changes too fast which causes changes in services then it’s worth considering to consolidate these services
  6. Analysis
    • Identify shared library and shared module dependencies
    • Document your versioning strategy for shared libraries
    • Break apart shared libraries into smaller context-based libraries
  7. Goals
    • Reduce the number of shared modules between services
    • Create fine-graned shared libraries to control change