Tutte le specialitàTecnologia · Colloquio di lavoro

Microservizi

Le domande sui microservizi sono in realtà domande sui compromessi. Di' che cosa guadagni, che cosa paghi e quando non lo faresti.

Parole → espressioni → frasi → parlato

Prova SpeakRole ↗
Colloquio di lavoroMicroservizi
V

How would you split a monolith into services without breaking data consistency?

0:18
Domanda dell’intervistatore

Microservizi

Chi ti intervista raramente vuole un elenco di pattern. Vuole capire come decidi: quando dividere in servizi vale il costo e come mantieni la coerenza dei dati senza un unico database.

Usa sempre lo stesso schema: il problema, il pattern, il compromesso. Se riesci ad aggiungere «per un team piccolo non lo farei», dai l'impressione di chi ha visto sistemi reali.

  • ✓Parole → espressioni → frasi → parlato
  • ✓Senso della risposta
  • ✓Lingua

Domande comuni e risposte di esempio

How would you split a monolith into services without breaking data consistency?

Come divideresti un monolite in servizi senza compromettere la coerenza dei dati?

Che cosa vuole sentire l'intervistatore. Un approccio graduale, confini chiari e uno sguardo onesto sulla coerenza.

Risposta di esempio in inglese da esercitare ad alta voce

I would not rewrite everything at once. First I find the business boundaries, for example orders, payments and users, and I move one of them out using the strangler approach: new traffic goes to the new service, and the old code stays until it is not needed. Each service should own its data, so I stop sharing tables. Where a business action touches several services, I use a saga with compensating steps instead of one big transaction. I also accept that some data will be consistent only eventually, so the product team must agree with that.

What is a saga, and when would you use one?

Che cos'è una saga e quando la useresti?

Che cosa vuole sentire l'intervistatore. Orchestrazione contro coreografia e azioni compensative.

Risposta di esempio in inglese da esercitare ad alta voce

A saga is a way to run a business process across several services without a distributed transaction. The process is split into local transactions. If one step fails, we run compensating actions for the steps that were already completed, for example refunding a payment. There are two styles. In choreography, services react to each other's events. In orchestration, one coordinator tells each service what to do. I prefer orchestration for longer flows, because the logic is in one place and easier to debug. Every step must be idempotent, because messages can arrive twice.

When do you choose synchronous calls, and when asynchronous messaging?

Quando scegli le chiamate sincrone e quando i messaggi asincroni?

Che cosa vuole sentire l'intervistatore. Accoppiamento, resilienza e ciò che vede l'utente.

Risposta di esempio in inglese da esercitare ad alta voce

I use synchronous calls, like REST or gRPC, when the caller needs the answer to continue, for example to check a price. The cost is coupling: if the other service is slow or down, the caller suffers. I use asynchronous messaging when the work can happen later, or when many services care about the same event, for example 'order created'. It gives better resilience and scaling, but debugging is harder, and the user may see data that is not updated yet. In many systems I combine both: a synchronous call at the edge and events inside.

What is a circuit breaker?

Che cos'è un circuit breaker?

Che cosa vuole sentire l'intervistatore. I tre stati e perché protegge chi effettua la chiamata.

Risposta di esempio in inglese da esercitare ad alta voce

A circuit breaker protects a service from a failing dependency. It watches the calls. When the number of errors or timeouts becomes too high, the circuit opens, and the next calls fail immediately or use a fallback instead of waiting. After some time, it lets a few test calls through, and if they succeed, it closes again. This stops a slow dependency from using all our threads and spreading the failure to other services. I combine it with timeouts and limited retries. Libraries like Resilience4j make this easy in Java.

How do you find a problem in a request that goes through many services?

Come individui un problema in una richiesta che attraversa molti servizi?

Che cosa vuole sentire l'intervistatore. Log, metriche e tracing, e l'abitudine di aggiungerli fin dall'inizio.

Risposta di esempio in inglese da esercitare ad alta voce

I rely on three things: logs, metrics and distributed tracing. Every request gets a trace ID at the entry point, and each service passes it on and writes it to the logs. With a tool like OpenTelemetry and a tracing backend, I can see the whole path of one request and where the time was spent. Metrics like latency and error rate per service tell me where to look first. Without this, a microservice system is almost impossible to debug, so I add it from the beginning, not after the first incident.

Come pronunciare i termini chiave

microservices
mài-cro-sèr-vi-siz
idempotent
ai-dem-pòu-tent
eventual consistency
i-vèn-ciu-al con-sìs-ten-si
saga
sà-ga
latency
lèi-ten-si
resilience
ri-zìl-iens

Frasi utili per rispondere

  • The main trade-off is…Il compromesso principale è…
  • I would start with a modular monolith.Partirei da un monolite modulare.
  • Each service owns its data.Ogni servizio possiede i propri dati.
  • We accepted eventual consistency here because…Qui abbiamo accettato la coerenza eventuale perché…
  • It depends on how much failure the business can accept.Dipende da quanti disservizi l'azienda può accettare.
  • I would add a timeout and a limited retry.Aggiungerei un timeout e un numero limitato di tentativi.

Errori comuni da evitare

  • Consigliare i microservizi per ogni problema. Una buona risposta dice quando è meglio un monolite, per esempio con un team piccolo o un dominio poco chiaro.
  • Parlare di pattern senza una storia di guasto. Spiega che cosa succede quando un servizio non risponde.
  • Dimenticare i dati. Molti problemi dei microservizi sono problemi di dati, quindi di' a chi appartengono.
  • Dimenticare le persone. I servizi seguono la struttura dei team, quindi cita la responsabilità sul servizio (ownership) e la reperibilità (on-call).

Domande frequenti

Devo consigliare i microservizi al colloquio?

Consiglia ciò che si adatta al caso e mostra di capirne il costo. Molti intervistatori si aspettano che tu parta da un monolite modulare e lo divida più avanti.

Quali strumenti conviene citare?

Quelli che hai usato, per esempio Kafka o RabbitMQ per la messaggistica, Kubernetes per il deployment e OpenTelemetry per il tracing. Non elencare strumenti di cui hai solo letto.

Come spiego la coerenza eventuale a una persona non tecnica?

Usa un esempio quotidiano: un bonifico bancario che per qualche secondo risulta «in elaborazione». Il sistema è corretto, sono solo le schermate che si aggiornano un attimo dopo.

Leggere una risposta non è la stessa cosa che dirla. Esercita ogni domanda ad alta voce, poi confronta il significato e la lingua della tua risposta.

Prova SpeakRole ↗

Altri argomenti in quest’area