Is there a pattern to put API Proxy / API into maintenance mode ?

If we would like to return a 503, momentarily, what options I can consider in Apigee Edge ?

~~Q:S:S~~

Solved Solved
0 4 573
1 ACCEPTED SOLUTION

One approach is to put a new api configuration entry, e.g. "toggle.maintenancemode: "enabled" in KVM.

Cache it so you don't hit the data store for every request - https://community.apigee.com/articles/24906/a-pattern-for-caching-kvm-values.html

In PreFlow, read api configuration (from KVM or from cache) and use RaiseFault policy to return 503 if maintenance mode is enabled. Optionally return Retry-After header to optimise clients polling for data.

When you want to put API proxy in maintenance mode, modify the KVM entry (disabled -> enabled) and invalidate cache so API proxy can pick up the changes immediately.

When you want to end the maintenance mode, modify the KVM entry (enabled -> disabled) and invalidate cache.

View solution in original post

4 REPLIES 4

One approach is to put a new api configuration entry, e.g. "toggle.maintenancemode: "enabled" in KVM.

Cache it so you don't hit the data store for every request - https://community.apigee.com/articles/24906/a-pattern-for-caching-kvm-values.html

In PreFlow, read api configuration (from KVM or from cache) and use RaiseFault policy to return 503 if maintenance mode is enabled. Optionally return Retry-After header to optimise clients polling for data.

When you want to put API proxy in maintenance mode, modify the KVM entry (disabled -> enabled) and invalidate cache so API proxy can pick up the changes immediately.

When you want to end the maintenance mode, modify the KVM entry (enabled -> disabled) and invalidate cache.

Thank you @oseymen@apigee.com , This is helpful. So, Just confirming, We are caching the KVM entry "toggle.maintenancemode": "enabled" in Apigee Cache Right ? Instead of directly accessing the KVM value we will access same from cache to minimize the response time from proxy.

That's right @Anil Sagar. What I generally do is to create a new KVM to store all configuration items for an API proxy, e.g. identity-v1-configuration. I'd put things like cache TTLs, token expiry, spike/quota values, etc in there. If I am implementing feature toggling, I'd put the toggles in there as well. I'd consider "maintenance mode" as part of that configuration KVM as a separate entry.

In my proxies, I cache the whole KVM - including all entries in it. I do this to prevent putting unnecessary load on C* during runtime. If configuration is changed, cache can be invalidated so changes can be read immediately. There is more info on this in the article I put in my answer.

Thanks @oseymen@apigee.com , This is super helpful.