Blogs

  • Home
  • Blog
  • Best Practices for the development of Microservices

Best Practices for the development of Microservices

Best Practices for the development of Microservices

From the experience of many projects , we have compiled a guide for the development of microservices.

 

Kubernetes Special Features

Writing to the hard disk

Write to root always on layered filesystem.
In Kubernetes, there is a special storage for volatile writes.
Root filesystem should always be mounted read only.

Loadbalancing

Scaling in Kubernetes only Horizontal
Services are always run behind load balancers.
Standard answer for HA and Selfhealing

Liveliness probes/Watchdog

Basically, error conditions should be identified in the service if possible.
However, health checks should not work to uniquely identify
From Kubernetes point of view standard response for self-healing

 

Scale out requirements

Stateless

Services should be stateless if possible.
If a state cannot be avoided, it must be made known to all instances
Kubernetes Service LBs donot support Sticky Sessions. Only possible by Tricks.

Fault Tolerant

Errors are normal and happen (Liveliness Probes!).
Example: At least once vs. at most once messaging (Acknowledged messaging vs Fire and forget).

Autonomy

Self-contained system, responsibility transitions
Services decide about all states completely and autonomously.
Example: deletion, config, transactions

Consistency

Every services is responsible for it’s own consistency
Attention! Observe dependencies to other services.

Queueing

Queueing helps to smooth load peaks because processing can be delayed.
Very suitable for time- or compute-intensive tasks.
Attention! Asynchrony is very amplified here. (Several requests against the same information can overtake each other. Race Conditions!)

 

Other Planning Support

Avoid shared resources

Microservices are based on maximum parallization
They always act in a serialized way

Configuration

Statistic Configuration by environment variable
For large configuration sets also via Config files.
dynamic configuration in application dabase​

Caching

Strong means for performance and to reduce computing power
Use only for read accesses if possible
Invalidate cache after writes
For large volumes and infrequent writes, cache should be created in the background

 

Challenges with Microservices

Microservices are distributed systems

Distributed systems are always subject to compromises
CAP Theorem
Eventual Consistency​
IMPORTANT. This decision must be made consciously

Problems

Special attention for deletion, backup, etc.
Transactions only by overlapping ID Possible
Worst case freeze => contradicts autonomy and therefore does not scale! ​​

 

 

Check out our latest blogpost


Kubernetes in Focus: An Outlook on Future Growth Areas

Die Weiterentwicklung von Kubernetes: Von hybriden Architekturen bis zur Cloud-übergreifenden Interoperabilität. Ein Vorgeschmack auf morgen.

Any Questions?

Please feel free to contact us for any question that is not answered yet. 

We are looking forward to get in contact with you!

Design Escapes

KubeOps GmbH
Hinter Stöck 17
72406 Bisingen
Germany

  • Telefon:

    +49 7433 93724 90

  • Mail:

    This email address is being protected from spambots. You need JavaScript enabled to view it.

Download Area
Certified as

KubeOps GmbH is the owner of the Union trademark KubeOps with the registration number 018305184. 

© KubeOps GmbH. All rights reserved. Subsidiary of