In a server-side web framework, what does installing a plugin or module actually do to the application?
answer
- a wiring unit, not a runtime call
- everything happens while booting
- registers components, hooks, defaults
- install order can decide conflicts
basics
~20 sInstalling a plugin runs its registration code against the application at startup: it adds components to the object graph, attaches request-pipeline hooks, and contributes overridable defaults. It is wiring executed once, not a per-request call.
solid answer
~40 sA plugin or module is a **unit of wiring** the framework knows how to apply. Installing it hands the plugin the application while it is still being built, and the plugin registers what its feature needs: components in the object graph, hooks in the request pipeline, sometimes routes, plus default settings read from configuration. All of that happens once, during startup; at request time the feature is simply already wired. The value is packaging — the same feature could be hand-wired line by line, but a plugin keeps registrations that belong together in one versioned unit. Most frameworks let the install call take a configuration block so the caller can adjust the defaults on the spot, and install order can matter when two plugins reach for the same slot.
go deeper
Be able to say that installing a plugin runs registration code once, while the application is being built, and to name what it registers: components, request-pipeline hooks and default settings.
Explain the install call as ordinary code that mutates the application under construction, and show how a configuration block passed at install time changes the defaults before anything is registered.
Talk about the failure modes: an install that throws should stop the boot, a unit installed twice may double its hooks, and two units competing for one slot must be resolved deliberately rather than by accident of order.
Weigh packaging a house feature as an installable unit for many services against letting each service wire it: the unit buys consistency and a single upgrade point, and costs you an ownership and versioning commitment.
## What a plugin or module actually is A **plugin** — different frameworks call it a module, an extension, a feature, or simply an installable unit — is a *bundle of registrations* that the framework knows how to apply to an application under construction. It is not the same thing as a library. A library is code you can call; the plugin is the thin layer that says **how that code attaches to this application**: what it places in the object graph, what it hangs on the request pipeline, what defaults it assumes, and which of those the caller may change. That distinction is the whole point of the question. Adding a package to the build makes code *available*. Installing a plugin makes it *wired*. Some frameworks blur the two by discovering installable units automatically from what is present in the build; others require an explicit install call. Either way, a registration step runs — the only difference is whether you typed it. ## What the install step does 1. The framework hands the plugin a handle on the **application being built** — the registry of components, the pipeline, the route table, the settings already loaded. 2. The plugin **registers components**: the objects its feature needs, usually keyed by the role they fill, so handlers and other components can depend on that role rather than on a concrete class. 3. The plugin **attaches hooks** to the request pipeline if its feature has to see traffic, and may **add routes** of its own (a status or metadata endpoint, for example). 4. The plugin **reads settings and contributes defaults** for anything the caller did not specify. 5. The framework **records that the unit is installed**, which is what lets later code ask whether the feature is present and lets a repeat install be detected. None of this is a per-request activity. What runs per request is whatever the plugin *registered* — the hook, the handler, the component method. Confusing the two is the classic junior mistake. ## Install time versus request time | Moment | What happens | Cost profile | |---|---|---| | Install (startup) | Registration code runs once; components created or their factories recorded; hooks appended; defaults filled in | Paid once; a failure here should stop the boot | | First request after boot | Anything the plugin deferred — a lazily created component, a warm-up — may resolve now | One-off latency on an early request | | Every request | Only the hooks and components the plugin registered | The steady-state cost the feature adds | ## Defaults and the configuration block Most installable units are designed to be useful with no arguments, so they carry defaults: a format, a size limit, a timeout, an encoding. Frameworks expose two seams for changing them: - a **configuration block passed at install time**, which the plugin applies to its own settings object before registering anything; - **externalised settings** the plugin reads, so the same build behaves differently per environment. A well-built unit also **stands aside** when the application has already registered something for a role it would fill, rather than overwriting it. Not every framework does this, and not every plugin inside a framework that does — which is exactly why "where did that default come from" is a real debugging question rather than a rhetorical one. ## Ordering, repeat installs and failure - **Order can decide the outcome.** If two units register for the same single-slot role, the surviving registration usually depends on which install ran last (or first — frameworks differ). If they both append to a pipeline, order decides the sequence rather than the winner. - **Repeat installs are not uniformly safe.** Some frameworks treat a unit as installed-once and ignore the second call; others happily register everything twice, producing a hook that runs twice per request. - **Install failures belong at boot.** A missing required setting or an unreachable resource discovered during installation should fail the startup loudly. Deferring that check to the first request turns a boot failure into a production error on a live user's request. ## What a plugin is not It is not a separate process, not a runtime code-injection mechanism, and not a substitute for understanding the wiring. Everything a plugin does, you could do by hand in the same startup code — which is the right mental model to hold when a plugin surprises you. The install is ordinary code; the reason it feels magical is only that you did not write it.
- If a feature can be hand-wired in ten lines, why package it as an installable unit at all?Because those ten lines must be correct in every service that needs the feature, and they change together. An installable unit keeps the registrations, their defaults and their relative order in one versioned place, so an upgrade is a version bump instead of the same edit repeated in every service. Below that scale, hand-wiring is usually clearer and easier to trace.
- What should happen when a plugin's install step finds a required setting missing?It should fail the startup, loudly and with the setting's name in the message. Installation is the last cheap moment to detect it: the process is not serving traffic yet, and the failure is attributable to one unit. Deferring the check turns a boot-time misconfiguration into an error on a real user's request, far from its cause.
saying these in an interview costs you the question
- Thinks a plugin's code runs on every request rather than at startup
- Cannot say what a plugin registers beyond 'it adds the feature'
- Assumes a plugin's defaults are fixed and cannot be overridden
- Believes adding a package to the build is the same as installing it
- Assumes install order never changes the result