Functional Decomposition

Every instance behind the load balancer still bundles two things that do not grow at the same rate. The registrar’s own staff use the application at a fairly steady pace. The API’s traffic, driven by CourseTracker and by every other developer who registers, is what keeps growing. Adding instances to keep up with the API also adds copies of the registrar’s own application that its own traffic does not need.

The coupling runs the other way too. A change to the registrar’s own application, a bug fix with nothing to do with the API, still means redeploying every instance, and that may require downtime for the API along with it.

The fix is to stop bundling them. Split the registrar’s application and the API into two separate services, each with its own instances, each scaled to its own traffic. A service is a part of the system that can be run, deployed, and scaled on its own. This kind of split, by function rather than by copying, is called functional decomposition.

The API’s constraint said it must run on the registrar’s existing hosting platform, next to the registrar’s system. That constraint made sense when the API was new and its load was unknown. It no longer applies to an API whose traffic keeps growing on its own. So we go back to the registrar’s office, the stakeholder that owns that constraint, and ask to drop it.

Suppose the registrar’s office agrees: the API becomes its own service, with the registrar’s application as another service running alongside it. Both services can now be run and scaled independently.

graph TB
    subgraph "Clients"
        A[People using the registrar's application]
        B[Other systems using the API, e.g. CourseTracker]
    end

    GW[API Gateway]

    subgraph "Services"
        APP[Registrar's Application]
        API[Registrar's API]
    end

    DB[(Database)]

    A --> GW
    B --> GW
    GW --> APP
    GW --> API
    APP --> DB
    API --> DB

Once there are two different services instead of one bundle, a request needs to be routed to the right one. That is a different job than we gave the load balancer here, which is to choose among identical copies of a single service. An API gateway is what does this.