Interview Q&A

Technical interview questions with detailed answers—organized by course, like Dot Net Tutorials interview sections. Original content for Toolliyo Academy.

Popular tracks

Microservices Microservices with .NET · Microservices

  • If services need complex queries and relationships (e.g., joins, foreign keys),

a relational database (SQL) might be suitable.

  • If the data access is simpler, more flexible, or requires high scalability, a

NoSQL database (e.g., MongoDB, Cassandra) might be better.

Permalink

Microservices Microservices with .NET · Microservices

  • Use gRPC or Protocol Buffers instead of HTTP/REST for faster

communication between services.

  • Minimize the number of network hops or remote procedure calls (RPCs)

needed for a task.

Permalink

Microservices Microservices with .NET · Microservices

microservices all at once, which can lead to unnecessary complexity and instability.

It’s important to gradually break down the monolith into microservices, focusing on

business capabilities first.

Permalink

Microservices Microservices with .NET · Microservices

deployment, where each region registers its services with a central registry, ensuring

that services in one region can discover services in another region.

Permalink

Microservices Microservices with .NET · Microservices

(e.g., an order is placed).

Permalink

Microservices Microservices with .NET · Microservices

name) for accessing a set of pods. When a pod’s IP address changes (due to scaling

or restarting), the service ensures the connection remains intact by updating the DNS

record.

Permalink

Microservices Microservices with .NET · Microservices

retries with exponential backoff to prevent cascading failures. Be careful with retry

logic to avoid creating further load during failures.

Permalink

Microservices Microservices with .NET · Microservices

  • The API Gateway becomes a critical point of failure for the system. If it goes

down, all services are affected.

  • Mitigation: Implement high availability with load balancing, auto-scaling,

and failover mechanisms.

Permalink

Microservices Microservices with .NET · Microservices

  • Maintain two identical environments (Blue and Green). Traffic is routed to one

(e.g., Blue) while the new version is deployed to the other (Green). After

testing, switch the traffic to the Green environment.

Permalink

Microservices Microservices with .NET · Microservices

  • Identify and define roles (e.g., Admin, User, Manager) within your system and

the permissions each role should have.

Permalink

Microservices Microservices with .NET · Microservices

  • Break a long-running transaction into smaller steps, where each step is a

local transaction managed by a single microservice. Use compensation

actions for each step to ensure consistency.

Permalink

Microservices Microservices with .NET · Microservices

data consistency and avoid issues like eventual consistency.

Permalink

Microservices Microservices with .NET · Microservices

Config, or HashiCorp Vault to manage configuration in a central,

environment-specific location.

Permalink

Microservices Microservices with .NET · Microservices

deployment, scaling, and management of containerized applications. It allows you to:

  • Automate scaling of services based on load.
  • Manage service discovery and load balancing.
  • Monitor and manage containers and their states.
Permalink

Microservices Microservices with .NET · Microservices

  • Scales the number of pod replicas based on observed CPU utilization,

memory usage, or custom metrics (e.g., request count).

  • Example: If the Order Service experiences a high load, Kubernetes can

automatically add more pod replicas to handle the increased traffic.

Permalink

Microservices Microservices with .NET · Microservices

(e.g., number of concurrent users).

Permalink

Microservices Microservices with .NET · Microservices

that a transaction either commits or rolls back across multiple services.

Permalink

Microservices Microservices with .NET · Microservices

  • Kubernetes DNS allows services to be accessed via DNS names (e.g.,

payment-service.default.svc.cluster.local).

  • Each service is associated with an internal IP address and a DNS entry.
Permalink

Microservices Microservices with .NET · Microservices

dependencies like databases, APIs, or other services are involved.

Permalink

Microservices Microservices with .NET · Microservices

RESTful APIs. It provides a standardized format that can be used for automatic

generation of API documentation, which can be easily shared and integrated with

tools like Swagger UI.

Permalink

Microservices Microservices with .NET · Microservices

request’s URL, method, and other factors.

Permalink

Microservices Microservices with .NET · Microservices

accessed data close to the services, reducing load times and network calls.

Permalink

Microservices Microservices with .NET · Microservices

  • Request rate (requests per second)
  • Error rate (percentage of failed requests)
  • Latency (time taken for a request to be processed)
Permalink

Microservices Microservices with .NET · Microservices

including which microservices were involved and how long each service took to

process the request.

Permalink

Microservices Microservices with .NET · Microservices

especially when the Payment Service was down, causing a failure in order creation.

Permalink

Microservices Microservices with .NET · Microservices

(e.g., a user's data). The client receives an access token.

Permalink

Microservices Microservices with .NET · Microservices

  • Kubernetes uses the Kubernetes Service resource (e.g., ClusterIP,

NodePort, LoadBalancer) to manage internal and external traffic to services.

  • Kube-proxy on each node handles load balancing of incoming requests to

service endpoints.

Permalink

Microservices Microservices with .NET · Microservices

microservices in a pipeline.

Permalink

Microservices Microservices with .NET · Microservices

calls to failing services.

Permalink

Microservices Microservices with .NET · Microservices

  • Retry failed operations with exponential backoff (e.g., retry every 1s, 2s,

4s, 8s) to avoid overwhelming the system. This is especially useful for

transient failures like network issues.

Permalink

Microservices Microservices with .NET · Microservices

  • The API Gateway can forward requests from clients to the appropriate

microservice, effectively acting as a reverse proxy.

Permalink

Microservices Microservices with .NET · Microservices

increasing the number of pods or adjusting resource allocation.

Permalink

Microservices Microservices with .NET · Microservices

Microservices are an architectural approach where an application is divided into small,

independently deployable services, each focused on a specific business function. These

services communicate with each other over APIs and are developed, deployed, and scaled

independently.

Monolithic architectures, in contrast, bundle all components of an application into a single,

tightly coupled unit. Changes or scaling require the entire application to be redeployed.

Key Differences:

  • Microservices offer modularity, scalability, and independent deployment, while

monolithic is a single, tightly integrated system that can be harder to scale and

maintain as it grows.

Permalink

Microservices Microservices with .NET · Microservices

failures (e.g., killing services or introducing network latency).

Permalink

Microservices Microservices with .NET · Microservices

downstream services (e.g., APIs, databases).

Permalink

Microservices Microservices with .NET · Microservices

  • Version the API via the URL, for example, /v1/orders and /v2/orders.
  • Example:

for version 1, and

for version 2.

Permalink

Microservices Microservices with .NET · Microservices

authorized based on their identity and behavior.

Permalink

Microservices Microservices with .NET · Microservices

registry, providing information like service name, IP address, port, health status, etc.

Permalink

Microservices Microservices with .NET · Microservices

  • Set a max retry limit to prevent infinite retry loops.
  • Introduce exponential backoff between retries. For example, first retry after

1 second, then 2 seconds, then 4 seconds, and so on.

Permalink

Microservices Microservices with .NET · Microservices

when a service is down and redirect requests to a fallback service.

Permalink

Microservices Microservices with .NET · Microservices

independent releases, making it easier to implement CI/CD pipelines. Each service

can be deployed and updated independently, minimizing risk.

Permalink

Microservices Microservices with .NET · Microservices

to prevent cascading failures.

Permalink

Microservices Microservices with .NET · Microservices

and potential failures.

Permalink

Microservices Microservices with .NET · Microservices

sessions by setting a cookie (e.g., nginx-ingress-controller) that ensures

subsequent requests from the same client go to the same service instance.

Permalink

Microservices Microservices with .NET · Microservices

sync. However, this approach can lead to performance bottlenecks and higher

latency.

Permalink

Microservices Microservices with .NET · Microservices

  • Implement centralized logging, metrics collection, and distributed tracing

to track and understand the system’s state.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

  • Set up an Authorization Server (e.g., Auth0, Keycloak, Okta) to manage

OAuth tokens.

Permalink

Microservices Microservices with .NET · Microservices

  • Use JWT tokens (which are included in the Authorization header, not cookies)

to avoid reliance on cookies for authentication, making CSRF attacks less

likely.

Permalink

Microservices Microservices with .NET · Microservices

transaction across multiple services. While this guarantees consistency, it can be

slow and introduces high overhead.

Permalink

Microservices Microservices with .NET · Microservices

APIs. Contract testing ensures that the contract (e.g., API request/response format)

is adhered to on both sides.

Permalink

Microservices Microservices with .NET · Microservices

assigned dynamic addresses (e.g.,

payment-service.default.svc.cluster.local in Kubernetes).

Permalink

Microservices Microservices with .NET · Microservices

deployments, helping you control how requests are routed between services.

Permalink

Microservices Microservices with .NET · Microservices

  • Services in a microservices architecture are often dynamic and can scale up

or down or change IP addresses.

  • Solution: Use service registries (e.g., Eureka, Consul, Kubernetes) that can

track and update service availability dynamically.

Permalink

Microservices Microservices with .NET · Microservices

  • The API Gateway can be integrated with OAuth 2.0 to authenticate incoming

requests by verifying the OAuth token.

  • Example: Check for a valid JWT token passed in the request header

(Authorization: Bearer <token>).

Permalink

Microservices Microservices with .NET · Microservices

  • Used to determine if a service is alive and functioning. If the liveness probe

fails, Kubernetes will restart the container.

  • Example: A database connection check can be implemented as a liveness

probe.

Permalink

Microservices Microservices with .NET · Microservices

stream (event log), making it easier to scale and distribute the system.

Permalink

Microservices Microservices with .NET · Microservices

backward-compatible, so that existing services continue to work with old versions of

the schema.

Permalink

Microservices Microservices with .NET · Microservices

can be partitioned by business domain. For example, the Order Service might have

its own database, and the Customer Service has another one.

Permalink

Microservices Microservices with .NET · Microservices

change occurs, such as creating a new order or processing a payment. The event is

typically sent to a message broker like Kafka or RabbitMQ.

Permalink

Microservices Microservices with .NET · Microservices

could cause downstream failures.

Permalink

Microservices Microservices with .NET · Microservices

  • The API Gateway can log every incoming request, the response, and the time

taken for each service call, centralizing logging for easier monitoring.

  • Example: Logstash or Elasticsearch can aggregate logs at the gateway

level for all requests.

Permalink

Microservices Microservices with .NET · Microservices

  • Use a retry template or middleware to automatically retry failed requests

based on certain conditions (e.g., retries for network timeouts or temporary

unavailability).

Permalink

Microservices Microservices with .NET · Microservices

case of failure.

Permalink

Microservices Microservices with .NET · Microservices

  • In stateful applications, requests from the same user need to go to the same

service instance. Handling this with load balancing can be challenging,

especially in a stateless microservices setup.

Permalink

Microservices Microservices with .NET · Microservices

  • Clients interact with a single API Gateway instead of multiple microservices,

reducing complexity on the client side.

  • Example: Clients don’t need to know the exact endpoint for each service; they

only interact with the API Gateway.

Permalink

Microservices Microservices with .NET · Microservices

traffic. Service discovery helps clients locate the right instances of services.

Permalink

Microservices Microservices with .NET · Microservices

  • A circuit breaker monitors failures and trips (opens) if a service experiences

repeated failures, preventing further calls to the failing service and giving it

time to recover.

  • Tools: Hystrix, Resilience4j.
Permalink

Microservices Microservices with .NET · Microservices

RESTful endpoints with consistent, versioned URLs.

Permalink

Microservices Microservices with .NET · Microservices

or real message brokers like Kafka or RabbitMQ.

Permalink

Microservices Microservices with .NET · Microservices

Consul, Eureka) to find available instances of the service it needs to communicate

with. Once the client knows the available instances, it directly calls the service.

Example: The Order Service queries Eureka to get the available instances of the

Payment Service.

Permalink

Microservices Microservices with .NET · Microservices

processing the same event multiple times does not result in different outcomes. This

can be achieved by checking if the event has been processed before and skipping it

if so.

Permalink

Microservices Microservices with .NET · Microservices

exchanged between services is protected against eavesdropping and tampering.

Permalink

Microservices Microservices with .NET · Microservices

  • Use a global service registry like Consul or Eureka to register services

across multiple regions or clouds.

Permalink

Microservices Microservices with .NET · Microservices

notify other services to undo the changes made. For example, if a payment service

fails after inventory was reduced, the inventory service would listen for a "rollback"

event to restore stock.

Permalink

Microservices Microservices with .NET · Microservices

increases the delay between each retry attempt to avoid overwhelming the

system.

Permalink

Microservices Microservices with .NET · Microservices

interact.

Permalink

Microservices Microservices with .NET · Microservices

  • Stores, indexes, and searches log data. Elasticsearch provides fast search

capabilities for querying logs, metrics, and other data.

Permalink

Microservices Microservices with .NET · Microservices

cross-origin requests from trusted domains.

Permalink

Microservices Microservices with .NET · Microservices

  • Integrate the tracing libraries (e.g., Jaeger client, Zipkin client) into your

microservices to instrument HTTP requests, database calls, or other

significant events.

Permalink

Microservices Microservices with .NET · Microservices

update (based on a timestamp or version number) is considered the correct one.

Permalink

Microservices Microservices with .NET · Microservices

Continuous Deployment (CD) pipelines to manage deployments. This ensures each

microservice is independently tested and deployed, enabling quick and reliable

delivery of updates.

Permalink

Microservices Microservices with .NET · Microservices

authentication, rate-limiting, and access control.

Permalink

Microservices Microservices with .NET · Microservices

balancer.

Permalink

Microservices Microservices with .NET · Microservices

data is exchanged.

Permalink

Microservices Microservices with .NET · Microservices

  • Open-source monitoring and alerting toolkit designed for collecting

time-series metrics from microservices.

Permalink

Microservices Microservices with .NET · Microservices

monitor how long a request takes to travel through the system and where bottlenecks

occur.

Permalink

Microservices Microservices with .NET · Microservices

Availability, or Partition Tolerance—not all three. Microservices must be designed

to prioritize partition tolerance (PT) and decide how to balance consistency and

availability.

Permalink

Microservices Microservices with .NET · Microservices

business capabilities that can be made into separate services.

Permalink

Microservices Microservices with .NET · Microservices

same client are always sent to the same instance of a service.

Permalink

Microservices Microservices with .NET · Microservices

key.

Permalink

Microservices Microservices with .NET · Microservices

interactions.

Permalink

Microservices Microservices with .NET · Microservices

dividing services or resources (e.g., database connections, threads) into

isolated pools.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

(Elasticsearch, Logstash, Kibana), Fluentd, or Graylog. These allow you to

aggregate logs from multiple services into a single, searchable repository, making it

easier to troubleshoot and analyze issues.

Permalink

Microservices Microservices with .NET · Microservices

  • Partition the database into smaller, manageable parts (shards) based on a

key (e.g., user ID). Each microservice can manage its own shard.

Permalink

Microservices Microservices with .NET · Microservices

be challenging if services are frequently scaled or updated. Use health checks to

ensure only healthy services are discoverable.

Permalink

Microservices Microservices with .NET · Microservices

triggering actions.

Permalink

Microservices Microservices with .NET · Microservices

eventual consistency, meaning that data across services may not be immediately

synchronized. Handling eventual consistency can be challenging, especially when

dealing with critical operations that require immediate consistency.

Permalink

Microservices Microservices with .NET · Microservices

Keycloak) to handle user login and issue access tokens (JWT). The authentication

service verifies credentials (e.g., username/password) and provides tokens for users

to access microservices.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

Review the concept and prepare a concise verbal explanation with a real project example.

Permalink

Microservices Microservices with .NET · Microservices

  • Kong, AWS API Gateway, NGINX, Ambassador to handle authentication,

authorization, rate limiting, and traffic management.

Permalink

Microservices Microservices with .NET · Microservices

principle of independence.

Permalink

Microservices Microservices with .NET · Microservices

  • Spring Cloud Config enables centralized management of external

configuration properties for microservices. Configuration values (e.g.,

database URLs, service endpoints) can be stored in a versioned Git

repository or a file system, and services fetch their configurations

dynamically.

  • Spring Cloud Config Server serves as a centralized configuration server for

multiple services.

Permalink

Microservices Microservices with .NET · Microservices

  • Use TLS (HTTPS) to encrypt data in transit between services, preventing

eavesdropping and tampering.

Permalink

Microservices Microservices with .NET · Microservices

consistency where services are allowed to be temporarily inconsistent, but will

eventually converge to a consistent state through events. Event-driven architectures

with tools like Kafka or RabbitMQ are commonly used to propagate changes and

synchronize services.

Permalink

Microservices Microservices with .NET · Microservices

  • Use structured logging (e.g., JSON format) instead of plain text to make

logs machine-readable and easy to search and analyze.

Permalink

Microservices Microservices with .NET · Microservices

  • Use tools like Fluentd, Logstash, or Vector to collect logs from

microservices and forward them to a centralized log management system.

Permalink

Microservices Microservices with .NET · Microservices

reconstruct the state, providing an audit trail for all business actions.

Permalink

Microservices Microservices with .NET · Microservices

events. When a service updates data, it emits an event, and other services subscribe

to those events to update their own state.

Permalink

Microservices Microservices with .NET · Microservices

service-name.namespace.svc.cluster.local). Kubernetes automatically

registers services and their IP addresses with the DNS system.

  • For example, a service named payment-service in the default

namespace can be accessed at

payment-service.default.svc.cluster.local.

Permalink

Microservices Microservices with .NET · Microservices

infrastructure (e.g., Kubernetes DNS).

Permalink

Microservices Microservices with .NET · Microservices

support multiple versions of events, ensuring compatibility with older consumers.

Permalink

Microservices Microservices with .NET · Microservices

address and port when they start up.

Permalink

Microservices Microservices with .NET · Microservices

their own pool to avoid resource contention with non-critical services (e.g.,

notifications).

Permalink

Microservices Microservices with .NET · Microservices

event-sourcing database) where it logs every state change as an event.

Permalink

Microservices Microservices with .NET · Microservices

  • Example: GET /api/v1/orders/{id} vs. GET /api/v2/orders/{id}
Permalink

Microservices Microservices with .NET · Microservices

globally or per service.

Permalink

Microservices Microservices with .NET · Microservices

  • Horizontal scaling: Use auto-scaling groups (e.g., AWS EC2 Auto Scaling,

Azure VM Scale Sets) to scale services based on load.

  • Caching: Implement caching mechanisms (e.g., Redis, Amazon

ElastiCache) to offload frequently accessed data and reduce load on

databases.

  • Load Balancing: Use cloud-native load balancers (AWS ELB, Azure Load

Balancer, GCP Load Balancing) to distribute traffic across multiple

instances of your microservices.

  • Profiling and Monitoring: Continuously monitor your microservices'

performance using tools like Prometheus, Grafana, AWS CloudWatch, or

Azure Monitor.

Permalink

Microservices Microservices with .NET · Microservices

migrations independently, allowing teams to evolve services and databases without

affecting others.

Permalink

Microservices Microservices with .NET · Microservices

supports session affinity. The load balancer can route traffic to the same backend

server based on cookies or IP address.

Permalink

Microservices Microservices with .NET · Microservices

transactions in microservices without locking resources or requiring a distributed

transaction manager. Sagas break a transaction into smaller, manageable steps, with

each microservice handling its own local transaction.

Permalink

Microservices Microservices with .NET · Microservices

data) when a service is unavailable or slow.

Permalink

Microservices Microservices with .NET · Microservices

backward compatibility. This enables independent evolution of microservices without

breaking other services that depend on older versions.

Permalink

Microservices Microservices with .NET · Microservices

difficult. It's not easy to ensure that all services in a distributed environment either

commit or roll back changes in a single, atomic transaction. Solutions like the Saga

pattern or Eventual Consistency are commonly used instead.

Permalink

Microservices Microservices with .NET · Microservices

  • Managing and coordinating many services increases the complexity of the

system.

  • Mitigation: Use centralized monitoring (e.g., Prometheus, Grafana) and

service discovery (e.g., Consul, Eureka) to track services.

Permalink

Microservices Microservices with .NET · Microservices

  • Services must expose health check endpoints. These are periodically

checked by service discovery systems (like Consul, Eureka, or Kubernetes)

to ensure that only healthy services are available for discovery.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

  • Each microservice should have a version number to track changes and

ensure backward compatibility.

  • Use Semantic Versioning (SemVer) to indicate breaking changes, minor

improvements, and patch updates.

  • Maintain API versioning in microservices to ensure that different services can

interact without breaking functionality (e.g., /v1/orders, /v2/orders).

Permalink

Microservices Microservices with .NET · Microservices

  • Closed: Requests pass through normally.
  • Open: Requests are blocked, and fallback logic is applied.
  • Half-Open: After a timeout, a few test requests are sent to determine if

the service has recovered.

Permalink

Microservices Microservices with .NET · Microservices

  • Use event-driven architecture to propagate updates to multiple services.

Events are processed asynchronously, ensuring eventual consistency.

Permalink

Microservices Microservices with .NET · Microservices

  • The coordinator (typically a transaction manager) sends a prepare request

to all participant services (e.g., databases).

  • Each participant service checks if it can commit the transaction (e.g., by

ensuring its local transaction is successful) and responds with a vote (either

commit or abort).

Permalink

Microservices Microservices with .NET · Microservices

  • Use patterns like Bulkheads and Circuit Breakers to isolate failures and

prevent cascading issues.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

  • Store session and user state in distributed caches (e.g., Redis) or

databases instead of in the service itself.

Permalink

Microservices Microservices with .NET · Microservices

  • The API Gateway can handle OAuth 2.0 authentication, verifying that

requests contain valid tokens before forwarding them to the appropriate

service.

Permalink

Microservices Microservices with .NET · Microservices

microservices.

Permalink

Microservices Microservices with .NET · Microservices

"Payment Processed") and publishes them to a message broker.

Permalink

Microservices Microservices with .NET · Microservices

to maintain compatibility with older clients.

Permalink

Microservices Microservices with .NET · Microservices

external calls, so that they don't block indefinitely.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

OpenAPI or Swagger. This helps teams understand the expected inputs, outputs,

and behavior of each API endpoint.

Permalink

Microservices Microservices with .NET · Microservices

Consul, or etcd to manage configuration centrally. Each service can pull its

configuration from a central repository, making it easier to update configurations

across all environments.

Permalink

Microservices Microservices with .NET · Microservices

multiple microservices without having to log in separately to each one. This is

achieved through centralized authentication (e.g., Keycloak, OAuth2, or Okta).

Permalink

Microservices Microservices with .NET · Microservices

persistent messages (e.g., Kafka, RabbitMQ). This ensures messages are not lost

even if the broker crashes.

Permalink

Microservices Microservices with .NET · Microservices

services. To mitigate, you can use feature flags or test in isolated environments.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

  • The client directly queries a service registry to obtain the list of available

instances of a service. It then chooses a suitable instance to connect to.

  • Tools: Netflix Eureka, Consul, Zookeeper, Etcd.
Permalink

Microservices Microservices with .NET · Microservices

  • Microservices involve many independently deployed services, making it hard

to trace the flow of a single request across the system.

  • Mitigation: Use distributed tracing and correlation IDs to trace requests

end-to-end.

Permalink

Microservices Microservices with .NET · Microservices

  • With multiple microservices generating logs and metrics, it becomes difficult

to manage, search, and analyze the data.

  • Mitigation: Implement centralized logging and log aggregation to

consolidate logs from all services.

Permalink

Microservices Microservices with .NET · Microservices

service expectations before they reach production, reducing integration issues.

Permalink

Microservices Microservices with .NET · Microservices

acts as an intermediary, decoupling the services. It distributes the events to multiple

consumers.

Permalink

Microservices Microservices with .NET · Microservices

schemas. Use tools like Flyway or Liquibase for automatic version control.

Permalink

Microservices Microservices with .NET · Microservices

  • Leverage Istio or similar service meshes to automatically collect telemetry

data and ensure traffic management, monitoring, and observability across

services.

Permalink

Microservices Microservices with .NET · Microservices

ensures the system remains aware of service instances and can route requests to

healthy ones.

Permalink

Microservices Microservices with .NET · Microservices

  • A data processing pipeline that ingests, transforms, and forwards logs from

microservices to Elasticsearch.

Permalink

Microservices Microservices with .NET · Microservices

claims (e.g., roles, permissions). This token is used to access microservices securely.

Permalink

Microservices Microservices with .NET · Microservices

circuit breaker “opens” and stops the calls to the service.

Permalink

Microservices Microservices with .NET · Microservices

(using mTLS), and fine-grained authentication and authorization policies.

Permalink

Microservices Microservices with .NET · Microservices

schema do not break existing consumers. For example:

  • Backward compatibility: New fields are optional, and old consumers can

ignore them.

  • Forward compatibility: New consumers can handle missing fields gracefully.
Permalink

Microservices Microservices with .NET · Microservices

events from the event store.

Permalink

Microservices Microservices with .NET · Microservices

pods for each service and updates the Endpoints resource. When a pod is added or

removed, the service discovery system automatically updates the list.

Permalink

Microservices Microservices with .NET · Microservices

excess traffic if the queue length exceeds a threshold.

Permalink

Microservices Microservices with .NET · Microservices

  • Implement a fallback strategy (e.g., default values, cached data, or a

predefined response) when a service is unavailable.

Permalink

Microservices Microservices with .NET · Microservices

service-to-service communication across multiple regions, providing consistent

service discovery, load balancing, and security policies.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

manage infrastructure in a declarative way, ensuring reproducibility and scalability of

environments.

Permalink

Microservices Microservices with .NET · Microservices

my-service.my-namespace.svc.cluster.local) to the appropriate pod IPs.

Permalink

Microservices Microservices with .NET · Microservices

reverse proxy can then use this cookie to route subsequent requests from the same

user to the same service instance.

Permalink

Microservices Microservices with .NET · Microservices

and enforces role-based or attribute-based access control to determine if the user

has permission to access specific resources.

Permalink

Microservices Microservices with .NET · Microservices

identifier (like a UUID) that allows services to track which messages have been

processed. When a message with the same ID arrives, it’s ignored.

Permalink

Microservices Microservices with .NET · Microservices

JWT token can be shared between microservices, enabling secure access without

the need to re-authenticate.

Permalink

Microservices Microservices with .NET · Microservices

messages, and implement retry logic in case of failure. Consumers can retry

processing if they fail, ensuring events are eventually processed.

Permalink

Microservices Microservices with .NET · Microservices

proper deserialization, processing, and acknowledgment).

Permalink

Microservices Microservices with .NET · Microservices

prevent a failure in one service from affecting others.

Permalink

Microservices Microservices with .NET · Microservices

immutable log of state changes.

Permalink

Microservices Microservices with .NET · Microservices

  • Serverless: Use serverless compute options like AWS Lambda, Azure

Functions, or Google Cloud Functions for burstable or event-driven

workloads to avoid idle time.

  • Spot Instances: Use spot instances or preemptible VMs for non-critical

workloads that can tolerate interruptions, reducing costs significantly.

  • Resource Scaling: Configure autoscaling policies to match service demand,

ensuring you’re only paying for the resources you need.

Permalink

Microservices Microservices with .NET · Microservices

  • Kubernetes Pods: Group one or more containers (microservices) into a Pod

for management.

  • Deployment: Define a Kubernetes Deployment resource to manage the

lifecycle of microservices (like scaling, rolling updates).

  • Service Discovery: Use Kubernetes Services to expose the microservices

and manage internal communication.

  • Scaling and Autoscaling: Use Kubernetes to automatically scale services

based on traffic, ensuring that resources are efficiently utilized.

Example: After containerizing a User Service using Docker, you would deploy it to a

Kubernetes cluster using a Deployment and expose it with a Service for communication

with other microservices.

Permalink

Microservices Microservices with .NET · Microservices

Benefits:

Follow :

  • Scalability: Microservices allow for independent scaling of services based on

demand.

  • Faster Development: Small, focused teams can develop and deploy services

independently.

  • Resilience: A failure in one service doesn’t affect the whole system.
  • Technology Agnostic: Different services can be built using different technologies.

Challenges:

  • Complexity: Managing many services and their interactions can be difficult.
  • Data Management: Ensuring data consistency across services can be challenging.
  • Latency: Inter-service communication over a network can introduce latency.
  • Deployment Overhead: Managing multiple deployments requires a sophisticated

CI/CD pipeline.

Permalink

Microservices Microservices with .NET · Microservices

thread pools) for each microservice or component.

Permalink

Microservices Microservices with .NET · Microservices

unittest.mock for Python) to simulate interactions with external services, databases,

and other components.

Permalink

Microservices Microservices with .NET · Microservices

  • Use Canary Deployments or Blue/Green Deployments to safely roll out

changes. These methods allow you to deploy new versions gradually and roll

back easily if issues arise.

  • If a rollback is required, it can be as simple as redeploying the previous stable

version using container images or deployment configurations stored in a

versioned system.

Example: If the Order Service is updated to a new version and a bug is detected, you can

use Kubernetes or Docker to quickly roll back to the previous stable version of the container.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

minimize this, use local caching of service discovery results and reduce the

frequency of lookups.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

  • The API Gateway can decode and validate JWT tokens to authenticate users

and extract user roles for authorization.

  • Example: Verify the signature of the JWT and check its expiry before

forwarding the request to the microservices.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

  • The API Gateway can aggregate data from multiple microservices and return

a single response to the client, improving client experience.

  • Example: An order summary could include data from the order service,

inventory service, and shipping service.

Permalink

Microservices Microservices with .NET · Microservices

  • Managing routing, security, and versioning for multiple services via a single

gateway can become complex as the system scales.

  • Mitigation: Use configuration management tools and declarative

configurations to keep the gateway setup manageable.

Permalink

Microservices Microservices with .NET · Microservices

complex. The two-phase commit pattern is often not feasible due to performance

concerns, so patterns like Saga or Compensating Transactions need to be

adopted.

Permalink

Microservices Microservices with .NET · Microservices

clusters of Docker engines and provides features for scaling, load balancing, and

service discovery.

In microservices, orchestration is crucial to managing complex systems and scaling

individual services as needed.

Example: Kubernetes can automatically scale the Inventory Service when traffic increases

and roll out updates to the Payment Service without downtime.

Permalink

Microservices Microservices with .NET · Microservices

  • API Gateways can provide monitoring of service health, response times, and

usage patterns across the system, enabling easy observability.

  • Example: Use Prometheus or Grafana to collect metrics from the gateway

and monitor traffic, failures, and performance.

Permalink

Microservices Microservices with .NET · Microservices

Gateway, which then queries the service registry and forwards the request to the

appropriate service instance. Tools like Kubernetes provide built-in service discovery

by assigning DNS names to services, and Kubernetes automatically routes traffic to

available service instances.

Example: In Kubernetes, a Payment Service might be exposed by a Service

resource, and requests to this service are routed to healthy pods based on their

labels.

Permalink

Microservices Microservices with .NET · Microservices

authentication to secure the communication.

Permalink

Microservices Microservices with .NET · Microservices

encrypted databases using standards such as AES-256.

Permalink

Microservices Microservices with .NET · Microservices

pipelines and manage deployments.

Permalink

Microservices Microservices with .NET · Microservices

  • Ensure redundancy of services and resources, using auto-scaling and

multi-region deployment to handle increased load and failure scenarios.

Permalink

Microservices Microservices with .NET · Microservices

Follow :

  • Common concerns like security, logging, rate-limiting, and authentication

can be handled at the gateway, reducing redundancy in the services.

  • Example: Handling authentication at the gateway means each individual

microservice doesn’t need to implement its own authentication logic.

Permalink

Microservices Microservices with .NET · Microservices

to undo the successful steps. For instance, if the Payment Service fails, you can

trigger a Compensating action to cancel the previous order creation or refund the

payment.

Permalink

Microservices Microservices with .NET · Microservices

consistent.

Permalink

Microservices Microservices with .NET · Microservices

Services) to distribute traffic evenly across instances.

Permalink

Microservices Microservices with .NET · Microservices

  • Set timeouts on all inter-service calls to avoid hanging indefinitely. If a

service call exceeds the timeout, it should return an error and trigger

fallback mechanisms.

Permalink

Microservices Microservices with .NET · Microservices

response or route the request to an alternate service.

Permalink

Microservices Microservices with .NET · Microservices

dependencies on production systems.

Permalink

Microservices Microservices with .NET · Microservices

instances of services) and maintain performance.

Permalink

Microservices Microservices with .NET · Microservices

in responses, and specify which domains are allowed to access the resources.

Permalink

Microservices Microservices with .NET · Microservices

URLs, API keys, etc.) in environment variables or configuration files.

Permalink

Microservices Microservices with .NET · Microservices

network partition, use eventual consistency models where services eventually

synchronize their data once the partition is resolved.

Permalink

Microservices Microservices with .NET · Microservices

lead to inter-service dependencies that are difficult to manage, increasing the

complexity and the risk of cascading failures.

Permalink

Microservices Microservices with .NET · Microservices

  • Use custom headers to specify the API version.

Follow :

  • Example: X-API-Version: v1 or Accept:

application/vnd.example.v1+json.

Permalink

Microservices Microservices with .NET · Microservices

to ensure service availability during high traffic or server failures.

Permalink

Microservices Microservices with .NET · Microservices

  • Stateful Services: If a service needs to keep track of user state (e.g., user

preferences, shopping carts), sticky sessions ensure the user’s requests are

directed to the same instance, preventing session data loss.

  • Consistency: In systems with user sessions (e.g., e-commerce platforms),

ensuring that all requests from a user go to the same instance prevents

inconsistencies in data retrieval.

Example: In an Authentication Service, where a user logs in and the session is maintained

on the instance, sticky sessions ensure that subsequent requests from that user are routed

to the same service instance.

Permalink

Microservices Microservices with .NET · Microservices

  • Automatically add instances of a service based on traffic or resource

consumption. Kubernetes' Horizontal Pod Autoscaler can automatically

scale services in response to load.

Permalink

Microservices Microservices with .NET · Microservices

  • Scaling Up: This involves increasing the resources (CPU, memory) for a

specific microservice instance. Vertical scaling is more common for monolithic

applications or services that require more powerful hardware but is less

optimal for microservices due to their distributed nature.

  • Example: Increasing the memory or CPU for a service like the Payment

Service that requires more processing power.

Best practice: For microservices, horizontal scaling is preferred because it increases

resilience and fault tolerance by distributing traffic and workloads across multiple instances.

Permalink

Microservices Microservices with .NET · Microservices

endpoints and enforce access controls.

Permalink

Microservices Microservices with .NET · Microservices

Follow :

  • If strong consistency and ACID transactions are required, SQL databases are

more appropriate.

  • For eventual consistency and high availability, NoSQL databases or

distributed databases might be better suited.

Permalink

Microservices Microservices with .NET · Microservices

frequently accessed data when the service is unavailable.

Permalink

Microservices Microservices with .NET · Microservices

failure, such as turning off analytics or limiting access to specific APIs while

keeping core functionality intact.

Permalink

Microservices Microservices with .NET · Microservices

different microservices may hold copies of the same data, which may take time to

synchronize. Techniques like Event Sourcing and CQRS help, but they often come

at the cost of performance.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

Responsibility Principle (SRP) in mind, meaning each microservice should expose

only the functionality related to its domain. Avoid "fat" endpoints that do too much.

Permalink

Microservices Microservices with .NET · Microservices

early and stop making requests to a service that is likely down, allowing time for

recovery.

Permalink

Microservices Microservices with .NET · Microservices

to trace requests across multiple services. This helps in understanding how requests

flow through the system and identifying bottlenecks.

Permalink

Microservices Microservices with .NET · Microservices

comparing versions. Services can merge changes or notify users about conflicts.

Permalink

Microservices Microservices with .NET · Microservices

  • Automatically adjusts CPU and memory limits for the pods to optimize

performance.

  • This is useful when pods experience resource contention but might not need

horizontal scaling.

Relevance to microservices: Kubernetes auto-scaling is essential in microservices to

ensure that each service can scale independently based on its needs, without manual

intervention. This allows the system to remain performant and available even as load

fluctuates.

Permalink

Microservices Microservices with .NET · Microservices

failures.

Permalink

Microservices Microservices with .NET · Microservices

clear path to migrate to newer versions.

Permalink

Microservices Microservices with .NET · Microservices

Follow :

  • Constantly updating the list of available service instances can put pressure on

the service discovery mechanism.

Permalink

Microservices Microservices with .NET · Microservices

Leaky Bucket to control the number of requests a user can make within a specified

Follow :

time period.

Permalink

Microservices Microservices with .NET · Microservices

systems, and testing in production means you have to ensure these dependencies

are not negatively impacted.

Permalink

Microservices Microservices with .NET · Microservices

  • If all participants vote to commit, the coordinator sends a commit message to

all participants, and the transaction is finalized.

  • If any participant votes to abort, the coordinator sends an abort message to

all participants, rolling back the transaction.

Follow :

Downsides: Two-phase commit can cause performance bottlenecks and is prone to

blocking if the coordinator or any participant fails during the process.

Permalink

Microservices Microservices with .NET · Microservices

the retry limit is reached.

Permalink

Microservices Microservices with .NET · Microservices

requests a specific service can use so that a failure in one service doesn’t

consume all resources.

Permalink

Microservices Microservices with .NET · Microservices

  • Use Web Application Firewalls (WAFs) to filter malicious or abnormal traffic.
Permalink

Microservices Microservices with .NET · Microservices

and decides which services to call next.

Permalink

Microservices Microservices with .NET · Microservices

  • If using cookies for session management, set the SameSite attribute to

Strict or Lax to ensure cookies are not sent with cross-site requests.

Permalink

Microservices Microservices with .NET · Microservices

  • Store sensitive data such as API keys, passwords, and tokens in

environment variables or secret management tools (e.g., HashiCorp

Vault, AWS Secrets Manager, Azure Key Vault).

Permalink

Microservices Microservices with .NET · Microservices

  • Assign roles to users or services (e.g., an admin role could have access to all

endpoints, while a user role might only have access to read certain

Follow :

resources).

Permalink

Microservices Microservices with .NET · Microservices

only the resources needed.

Permalink

Microservices Microservices with .NET · Microservices

breaking a transaction into smaller, isolated steps, each with its own local

transaction. It uses compensating actions to undo any step if a failure occurs in one

Follow :

of the microservices.

Permalink

Microservices Microservices with .NET · Microservices

eventually be consistent, even though there might be temporary inconsistencies.

To manage consistency:

Permalink

Microservices Microservices with .NET · Microservices

  • Gradually roll out changes to a small subset of users and monitor for issues.

Once the deployment is validated, gradually increase traffic to the new

Follow :

version.

Permalink

Microservices Microservices with .NET · Microservices

Review the concept and prepare a concise verbal explanation with a real project example.

Permalink

Microservices Microservices with .NET · Microservices

local state based on received events.

Permalink

Microservices Microservices with .NET · Microservices

send a single response to the client.

Permalink

Microservices Microservices with .NET · Microservices

Kafka) to decouple services and avoid blocking operations.

Permalink

Microservices Microservices with .NET · Microservices

Review the concept and prepare a concise verbal explanation with a real project example.

Permalink

Microservices Microservices with .NET · Microservices

business goals.

Permalink

Microservices Microservices with .NET · Microservices

Follow :

  • Istio, Linkerd, Consul to manage mTLS, service authentication, and traffic

encryption between microservices.

Permalink

Microservices Microservices with .NET · Microservices

  • It can enforce Role-Based Access Control (RBAC) by checking if the

authenticated user has the required permissions for the requested operation.

Permalink

Microservices Microservices with .NET · Microservices

  • Add context to logs by including metadata like request IDs, user IDs,

service names, and correlation IDs to trace requests across different

services.

Permalink

Microservices Microservices with .NET · Microservices

default responses or alternative services can be used.

Permalink

Microservices Microservices with .NET · Microservices

transactions, each handled by an individual service. Sagas manage failures by using

compensating actions, thus avoiding the need for distributed locking.

Permalink

Microservices Microservices with .NET · Microservices

events. This enables asynchronous processing and decouples services, reducing the

need for synchronous coordination, which would otherwise require a global

transaction manager.

Permalink

Microservices Microservices with .NET · Microservices

test, prod) to maintain separate configuration files. Tools like Spring Profiles or

Docker can be used to load the correct configuration based on the environment.

Permalink

Microservices Microservices with .NET · Microservices

external services (e.g., success, failure, timeouts).

Permalink

Microservices Microservices with .NET · Microservices

Resilience4j or Hystrix) are functioning correctly when services fail.

Permalink

Microservices Microservices with .NET · Microservices

service name to an IP address.

Consul:

Permalink

Microservices Microservices with .NET · Microservices

instances of another service and their details (e.g., IP, port).

Permalink

Microservices Microservices with .NET · Microservices

  • Use centralized logging platforms such as Elasticsearch, Logstash, and

Kibana (ELK Stack), Splunk, or Graylog to store and analyze logs.

Permalink

Microservices Microservices with .NET · Microservices

Service and Order Service had synchronized data, especially after a payment failure.

Permalink

Microservices Microservices with .NET · Microservices

and track a cookie containing information about which backend service instance to

route the request to.

Permalink

Microservices Microservices with .NET · Microservices

events. For example, the Inventory Service might listen for an OrderPlaced event

and update inventory quantities.

Permalink

Microservices Microservices with .NET · Microservices

services, but there might be temporary inconsistencies.

Permalink

Microservices Microservices with .NET · Microservices

order-service.my-namespace.svc.cluster.local).

Permalink

Microservices Microservices with .NET · Microservices

microservices or identify services that are causing performance issues.

Permalink

Microservices Microservices with .NET · Microservices

your services to keep track of changes over time and make sure consumers are

aware of breaking changes.

Permalink

Microservices Microservices with .NET · Microservices

API contract remains consistent over time. This involves verifying that each service

Follow :

meets the expectations of consumers and producers (e.g., using tools like Pact).

Permalink

Microservices Microservices with .NET · Microservices

  • Service discovery can fail if the service registry becomes unavailable.
  • Solution: Use redundant and fault-tolerant service discovery setups with

health checks, replication, and caching to minimize downtime.

Permalink

Microservices Microservices with .NET · Microservices

  • Used with Prometheus for visualizing metrics and building dashboards for

real-time monitoring.

Permalink

Microservices Microservices with .NET · Microservices

availability.

Permalink

Microservices Microservices with .NET · Microservices

instances, typically based on algorithms like round-robin, least connections, or IP

hashing.

Permalink

Microservices Microservices with .NET · Microservices

  • If one service instance becomes unavailable, the service discovery system

should be capable of routing requests to other healthy instances. This could

involve retry mechanisms or rerouting to secondary instances.

Permalink

Microservices Microservices with .NET · Microservices

  • The load balancer or API gateway queries the service registry to route

requests to available instances of a service.

  • Tools: Kubernetes DNS-based discovery, AWS ELB (Elastic Load

Balancer).

Example: In Kubernetes, services are registered automatically in Kubernetes DNS, and

services can discover each other by querying the service names.

Permalink

Microservices Microservices with .NET · Microservices

data is in one place.

Cons of a shared database:

Permalink

Microservices Microservices with .NET · Microservices

  • Increase the delay exponentially with each retry to avoid hammering the

service and allowing time for recovery.

Permalink

Microservices Microservices with .NET · Microservices

  • Indicates whether the service is ready to handle traffic. If the probe fails,

Kubernetes will stop sending traffic to the service.

  • Example: A HTTP endpoint (e.g., /health/ready) can be used to check if

the service has completed its initialization.

Example: In Kubernetes, configure a livenessProbe and readinessProbe for a User

Service that checks the database connection and ensures the service is ready before

accepting traffic.

Permalink

Microservices Microservices with .NET · Microservices

id=123&version=1

Permalink

Microservices Microservices with .NET · Microservices

microservices grows, making it harder to scale.

Permalink

Microservices Microservices with .NET · Microservices

based on the events they receive (e.g., the inventory service updates stock levels

when an order is created).

Follow :

Permalink

Microservices Microservices with .NET · Microservices

deployment, and scaling.

Permalink

Microservices Microservices with .NET · Microservices

  • CPU usage, memory usage, disk I/O for each service.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

delay, to handle transient failures.

Permalink

Microservices Microservices with .NET · Microservices

to a new version.

Permalink

Microservices Microservices with .NET · Microservices

discovery (e.g., payment-service.service.consul).

Permalink

Microservices Microservices with .NET · Microservices

changes and ensuring that services are compatible with different schema versions.

Permalink

Microservices Microservices with .NET · Microservices

  • Ensure that trace context (e.g., trace IDs) is passed between services to link

together different parts of the request journey.

Permalink

Microservices Microservices with .NET · Microservices

system.

Permalink

Microservices Microservices with .NET · Microservices

  • Use DNS-based service discovery (e.g., AWS Route 53, Consul DNS

integration) that supports multi-region failover, routing users to the nearest

region based on the DNS resolution.

Permalink

Microservices Microservices with .NET · Microservices

  • Ingress controllers provide HTTP and HTTPS load balancing, routing

external traffic to the appropriate services within the Kubernetes cluster.

  • Popular ingress controllers like NGINX, Traefik, and HAProxy handle routing

and load balancing across multiple service instances.

Permalink

Microservices Microservices with .NET · Microservices

  • Implement the Saga pattern to manage distributed transactions and

ensure consistency by using a series of compensating transactions in

case of failure.

Permalink

Microservices Microservices with .NET · Microservices

region), you can use a shard key to distribute data across multiple databases or

servers.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

  • Services can synchronize data by making HTTP or gRPC calls to other

services, requesting the data they need to keep their own data store in sync.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

automatically fetch updated configurations when deployed.

Permalink

Microservices Microservices with .NET · Microservices

  • Services may scale up and down dynamically, making it hard to track service

instances and their corresponding logs.

  • Mitigation: Use tools like Kubernetes and Service Meshes (e.g., Istio) to

track dynamic infrastructure and provide observability.

Permalink

Microservices Microservices with .NET · Microservices

events are durable and can be replayed if needed.

Permalink

Microservices Microservices with .NET · Microservices

of service endpoints.

Permalink

Microservices Microservices with .NET · Microservices

compatibility between different versions of APIs.

Tools:

  • Pact (most common for consumer-driven contract testing)
  • Spring Cloud Contract (for Java-based microservices)

Follow :

Permalink

Microservices Microservices with .NET · Microservices

  • Create real-time dashboards in tools like Grafana to visualize metrics, logs,

and traces for a comprehensive view of service health.

Permalink

Microservices Microservices with .NET · Microservices

first add the new field as nullable, then gradually update services to use it before

removing old columns.

Permalink

Microservices Microservices with .NET · Microservices

timeouts.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

client is authorized and has appropriate permissions. This is done by checking the

token's signature and expiration date.

Example: A client app (e.g., a mobile app) requests an access token from an OAuth

provider (e.g., Auth0), then includes the JWT token in the Authorization header when

calling microservices like GET /api/orders.

Permalink

Microservices Microservices with .NET · Microservices

if the service has recovered. If it succeeds, it closes the circuit again; otherwise, it

remains open.

Tools:

  • Hystrix (now deprecated but still widely used) and Resilience4j are popular Java

libraries that implement the Circuit Breaker pattern.

  • Istio and Envoy in service mesh environments can also be used for circuit breaking.

Example:

  • If a Payment Service is down, instead of retrying failed payment requests, the circuit

breaker opens, preventing overloading the service and allowing the system to fail

gracefully.

Permalink

Microservices Microservices with .NET · Microservices

that the architecture remains loosely coupled and scalable.

Example: In an E-commerce system, instead of updating an "Order" record in the

database, you store each event like OrderCreated, PaymentProcessed, etc., and replay

these events to determine the current state of the order.

Microservices Deployment & CI/CD

Permalink

Microservices Microservices with .NET · Microservices

tracing, and logging, helping you track and troubleshoot service interactions.

Permalink

Microservices Microservices with .NET · Microservices

  • Resilience4j provides support for retries, timeouts, circuit breakers, and

fallbacks in a microservices environment.

Example: In a Payment Service, if a payment request to an external provider fails, a

fallback could be to use an alternative payment gateway.

Follow :

Permalink

Microservices Microservices with .NET · Microservices

schemas and enforce rules on backward and forward compatibility.

Permalink

Microservices Microservices with .NET · Microservices

consistent across environments.

Permalink

Microservices Microservices with .NET · Microservices

Review the concept and prepare a concise verbal explanation with a real project example.

Permalink

Microservices Microservices with .NET · Microservices

which can lead to duplication of data across services. This introduces challenges in

keeping data synchronized between services, especially in the case of failures.

Permalink

Microservices Microservices with .NET · Microservices

latency help identify performance degradation.

Permalink