Markdown Editor

Microservice Specification Template (Service Canvas)

Service canvas: bounded context, owner, APIs and events, data owned, dependencies, SLOs, scaling, config, deploy, observability

Mode d'emploi: Use for each microservice, kept in its repository and linked from the service catalogue. Fill purpose, bounded context and data owned before building; link detailed API, event and runbook documents instead of copying them. Main pitfall: unlisted dependencies and shared databases that make the service boundary fictional.

Aperçu

Microservice Specification: [service-name]

One-page-per-service canvas that records what a microservice is for, who owns it, what it exposes and consumes, which data it owns, how it runs, scales, is observed and secured, and how it is versioned. Based on common industry practice for service canvases and service catalogue entries. Replace every [bracketed] value and every row marked Example. Worked examples use an inventory reservation service.

FieldValue
Service name[inventory-reservation]
Document version[0.1]
Status[Proposed / In development / Production / Deprecated]
Owning team[@team-inventory]
Technical owner[@tech-lead]
On-call rotation[inventory-oncall]
Repository[git URL]
Service tier[Tier 1 / Tier 2 / Tier 3]
Last updatedYYYY-MM-DD

1. Purpose and bounded context

1.1 Purpose

[One paragraph. Example: "Reserves stock for items in a checkout so that two customers cannot buy the last unit, and releases reservations that are not confirmed within 15 minutes."]

1.2 Bounded context

ItemValue
Domain / subdomainExample: Inventory / Availability (core subdomain)
Key domain termsExample: Reservation, stock keeping unit (SKU), available-to-promise, hold expiry
ResponsibilitiesCreate, confirm, release and expire reservations; publish availability changes
Not responsible forStock counts at warehouses (Warehouse service), prices (Pricing service), orders (Orders service)
Upstream contextsWarehouse (stock levels), Catalogue (SKU validity)
Downstream contextsCheckout, Orders, Storefront search

2. Ownership and lifecycle

RoleName / channel
Owning team[@team-inventory]
Product owner[@product-owner]
On-call escalation[Paging service], then [@engineering-manager]
Support channel[#inventory-help]
Lifecycle stage[Production since YYYY-MM-DD]
Planned changes[Example: Multi-warehouse reservations in Q2]

3. Interfaces

3.1 Exposed APIs

APIStyleContractConsumersAuth
POST /v1/reservationsREST[openapi.yaml#createReservation]CheckoutOAuth 2.0 client credentials, scope inventory:reserve
POST /v1/reservations/{id}/confirmREST[openapi.yaml]OrdersSame, scope inventory:confirm
DELETE /v1/reservations/{id}REST[openapi.yaml]CheckoutSame
GET /v1/availability?sku=REST[openapi.yaml]Storefront, SearchScope inventory:read
[API][REST / gRPC / GraphQL][Link][Consumers][Auth]

3.2 Consumed APIs

APIProviderPurposeTimeoutFallback if unavailable
GET /v2/skus/{sku}Catalogue serviceValidate SKU on reservation300 msUse cached SKU list (refreshed every 5 min)
[API][Provider][Purpose][Timeout][Fallback]

4. Events

4.1 Published events

EventChannelSchemaTriggerKey
ReservationCreatedinventory.reservation.v1[registry subject]Reservation storedsku
ReservationExpiredinventory.reservation.v1[subject]Hold timer elapsedsku
AvailabilityChangedinventory.availability.v1[subject]Available quantity crosses a thresholdsku
[Event][Channel][Schema][Trigger][Key]

4.2 Consumed events

EventChannelProducerHandlingIdempotency
StockAdjustedwarehouse.stock.v1Warehouse serviceUpdate on-hand quantityEvent ID stored for 7 days
OrderCancelledorders.order.v1Orders serviceRelease confirmed reservationReservation state check
[Event][Channel][Producer][Handling][Method]

5. Data owned

DataStoreClassificationRetentionShared how
ReservationsExample: PostgreSQL inventory_reservationInternal90 days after expiry or confirmationAPI and events only
Available-to-promise per SKURedis (derived, rebuildable)InternalLiveGET /availability
[Data][Store][Class][Retention][Mechanism]

No other service reads these stores directly. Reporting uses the published events.

6. Dependencies

DependencyTypeCriticalityFailure behaviour
PostgreSQLData storeHardReservations fail with 503; checkout shows "try again"
RedisCacheSoftAvailability served from database at higher latency
Message brokerMessagingSoftEvents buffered in outbox up to [6 hours]
Catalogue serviceAPISoftCached SKU list
[Dependency][Type][Hard / Soft][Behaviour]

7. Service level objectives

SLISLOWindowMeasured at
Availability of POST /reservations99.95% non-5xx28 days rollingGateway
Latency of POST /reservations99% under 150 ms28 days rollingGateway
Expiry accuracy99.9% of holds released within 60 s of expiry28 daysService metric
[SLI][SLO][Window][Point]

Error budget for availability in a 28-day window:

B=(1−0.9995)×28×24×60≈20 minutesB = (1 - 0.9995) \times 28 \times 24 \times 60 \approx 20\ \text{minutes}

8. Scaling and capacity

ItemValue
Expected loadExample: 120 reservations/s average, 900/s at sale start
Scaling modelHorizontal; stateless pods; HPA on CPU 60% and request rate
ReplicasMin 3 (one per zone), max 30
Known limitSingle hot SKU above 2 000 reservations/s contends on one row; mitigated with sharded counters
Load testLast run YYYY-MM-DD at 1 500 reservations/s

9. Configuration

KeyPurposeDefaultSource
HOLD_TTL_SECONDSReservation hold time900Environment
MAX_QTY_PER_RESERVATIONAbuse limit per request20Feature flag service
DB_URLDatabase connectionnoneSecrets manager inventory/db
CATALOGUE_BASE_URLCatalogue APIper environmentEnvironment
[KEY][Purpose][Default][Source]

10. Deployment

ItemValue
RuntimeExample: Container on Kubernetes, namespace inventory
Pipeline[CI system] build, test, scan, sign, deploy to staging, canary 10% for 15 min, full rollout
Environmentsdev, staging, production (two regions)
RollbackAutomatic on canary error rate above 1%; manual via [deploy tool] rollback
Database migrationsExpand and contract; run as a pre-deploy job
Release frequencyDaily

11. Observability

SignalWhereKey items
Metrics[Dashboard link]Request rate, error rate, p99 latency, active holds, expiry lag
Logs[Log query link]Structured JSON; fields reservation_id, sku, trace_id
Traces[Tracing link]Spans for database, cache, catalogue calls
Alerts[Alert rules link]SLO burn rate (fast and slow), expiry lag above 120 s, outbox age above 5 min
Runbook[Runbook link]One section per alert

12. Security

TopicControl
Inbound authenticationOAuth 2.0 tokens validated at gateway and service; mTLS in mesh
AuthorisationScope per endpoint (3.1); reservations can only be confirmed by Orders
Outbound identityWorkload identity; no static credentials
DataNo personal data stored; reservation references checkout session ID only
AbusePer-session limit of [5] active reservations; quantity cap
DependenciesImage and dependency scanning in CI; critical fixes within [7] days

13. Versioning and compatibility

ContractVersioningCompatibility promiseDeprecation notice
REST APIMajor version in path (/v1)Additive changes only within a major version[6 months], Deprecation and Sunset headers
EventsMajor version in channel nameRegistry enforces backward-compatible schemas[6 months] dual publishing
Service releaseSemantic versioning of the buildn/aRelease notes in [link]

14. Related documents

DocumentLink
REST API specification[link]
Event API specification[link]
Architecture decision records[link]
Runbook[link]
Threat model[link]

Standard and licence note

Based on common industry practice for microservice canvases and service catalogue entries. Original text written for this collection; example values are illustrative. Template licence: MIT.

Modèles associés