From Monolith to Cloud Native: Developer Role Evolution and When to Split Services

    This article explains how developer roles evolve from independent feature delivery to core module ownership and system-level architecture coordination. It discusses when monoliths, microservices, and cloud-native platforms are appropriate, with a focus on split signals and the reliability boundaries of message queues.

    Introduction: Decide on Complexity Before Choosing an Architecture

    A developer’s career typically progresses through three stages: first delivering features independently, then leading core modules, and finally participating in system-level architecture coordination. Each stage solves a different problem. Early on, the focus is on fast delivery; in the middle stage, on splitting modules while keeping them stable; later, on unifying rules across multiple teams. Architecture evolution aims to control complexity and clarify module boundaries. This article follows that path to explain the applicable conditions for monoliths, microservices, and cloud-native platforms, and to provide checkpoints for message queues, observability, and team configuration.

    1. When Monolithic Architecture Fits

    A monolithic architecture packages the user interface, business logic, and data access into a single deployment unit. For teams with few people and a business still being validated, it offers low development cost, straightforward local debugging, and simple testing and deployment. Developers can complete everything from table schema design to API release in a short time.

    Monolithic architecture is not inherently outdated. Many products use a monolith in their early stages and run stably for years. Problems usually appear after both the codebase and the team grow. The following signals can help determine whether splitting is needed:

    1. Multiple teams frequently modify the same codebase, and merge conflicts occur every week.
    2. Changing a small feature requires a full compile, the entire test suite, and a whole release.
    3. A failure in one module brings down the entire system, and the blast radius is hard to isolate.
    4. One module has significantly higher load than others, but scaling can only be done for the whole system.
    5. Modules call each other directly, and changing one place requires checking many dependencies.

    If only one or two signals appear, prioritize modular refactoring and draw clear package and interface boundaries within the same process. Only when multiple signals coexist over the long term is a microservice split worth the investment.

    At the monolith stage, a consistent log format and basic exception handling are the lowest-cost investments. Structured logs with request IDs can quickly locate production issues and also accumulate analyzable data for later splitting.

    2. Microservice Splitting and the Reliability Boundaries of Message Queues

    Microservices split a monolithic application by business boundaries into multiple independently deployed and independently scaled services. After the split, services communicate over the network, so the probability of failure and the difficulty of data consistency both increase. Message queues are often used to decouple these services: producers write events to the queue, and consumers process them at their own pace. A message queue can absorb peaks and isolate failures, but it cannot guarantee business correctness; the application layer must cooperate.

    Before using a message queue, clarify several prerequisites. Most message queues provide at-least-once delivery by default, meaning the same message may be delivered multiple times, so consumers must be able to handle duplicate messages. Most queues guarantee order only within the same partition or the same message key; global ordering across partitions usually cannot be guaranteed. Consumed messages do not roll back automatically. After a failure, retry, compensation, or manual handling is required.

    The following code is pseudocode to illustrate the processing flow. It cannot run directly. Actual class names, interfaces, and framework annotations need to be replaced with the corresponding versions for the chosen middleware.

    1. // Pseudocode: illustrates the flow only; not directly runnable
    2. // Producer: the order and event are written in the same local transaction,
    3. // then dispatched to the message queue by a separate job
    4. public class OrderService {
    5. private final OrderRepository orderRepository;
    6. private final OutboxRepository outboxRepository;
    7. public void createOrder(OrderInfo order) {
    8. transactionManager.runInTransaction(() -> {
    9. orderRepository.insert(order);
    10. outboxRepository.insert(
    11. OutboxEvent.of("order_created", order.getOrderId(), order.toPayload())
    12. );
    13. });
    14. }
    15. }
    16. // Consumer: idempotently handles inventory deduction, with a retry limit,
    17. // and enters the dead-letter queue after the limit is exceeded
    18. public class InventoryConsumer {
    19. private static final int MAX_RETRY = 3;
    20. public void onOrderCreated(OrderMessage message) {
    21. String idempotencyKey = message.getOrderId() + ":" + message.getProductId();
    22. if (processedRecords.exists(idempotencyKey)) {
    23. return; // Already processed; acknowledge directly to avoid duplicate deduction
    24. }
    25. try {
    26. inventoryService.deduct(message.getProductId(), message.getQuantity());
    27. processedRecords.mark(idempotencyKey);
    28. } catch (TemporaryException e) {
    29. if (message.getRetryCount() < MAX_RETRY) {
    30. retryQueue.send(message.withRetryCount(message.getRetryCount() + 1));
    31. } else {
    32. deadLetterQueue.send(message);
    33. alertService.notify("inventory deduction failed", message.getOrderId());
    34. }
    35. }
    36. }
    37. }

    This code contains four key points.

    First, the database write and the event send need to be decoupled. If the order is written to the database and then the message is sent directly, a process crash between the two steps will lose the message. The outbox pattern puts the order and the event in the same local transaction, and then a separate job dispatches the message, avoiding this inconsistency.

    Second, the consumer uses an idempotency key to determine whether a message has already been processed. Resends caused by network timeouts will not cause duplicate deductions.

    Third, the retry count has an upper limit. After it is exceeded, the message enters the dead-letter queue and triggers an alert. This prevents failed messages from looping indefinitely and consuming resources.

    Fourth, in the example, deduction and the deduplication record are two separate steps. In a real system, a crash between the two steps can result in a successful deduction but a missing deduplication record. A more robust approach is to put the deduplication record and the deduction in the same local transaction, or rely on a database unique constraint to ensure processing happens only once.

    Common mistakes in practice include the following.

    Sending a message without persisting the order. The message has been sent, but the order is not saved, so downstream processes a nonexistent order.

    Deducting inventory before sending the message. If message sending fails, inventory has already been deducted but downstream does not know, so the data will not match.

    No idempotency design. After a network timeout, the producer resends, and the consumer deducts inventory again.

    Dead-letter queues are left unmonitored.