-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp APIcast configuration loading #230
Comments
Can't it be simplified by eliminating the difference between boot and lazy. |
@MarkCheshire for example when you have cloud environment with 10000 services. Also the configuration loaded on boot is discarded when the first request comes and needs new configuration (like staging). That just creates dependency on a service that has to be running, but is not used until later when the actual request comes. |
@mikz what we could do is have 1 of the 2 behaviours as the default and have a 0/1 switch to enable the non-default behaviour. i.e. default could be load on boot or crash but for saas we would would set |
naming wise: In general it would be good if all APIcast configuration options would be in the same family of names: or all should be preceded with APICAST or none. I'd say none as it's pretty clear you are within APIcast context. |
@thomasmaas the true default would probably be the production setting: Then there are other combinations like:
Re the naming. I agree. #207 |
I assume the caching is done at the per service level. Can't you just eliminate option 3? Then the only load on boot is option 1. While in option 3 the config for each service is loaded when the first request arrives. It would simply things. |
@MarkCheshire that is how APIcast hosted works on-premises. It keeps all the configuration in memory so the first request is fast. It does not lazy load configuration to keep it production ready. |
@milkz so i would say we get rid of |
@thomasmaas and when we need to introduce 3rd state just change it again to be enum ? If the |
How much of a benefit it is for APIcast hosted on-prem to be able to load on boot? The penalty for lazy load is not that great if it is only the first call to each service that has to grab the config. |
AUTO_UPDATE_INTERVALI would change this as: AUTO_UPDATE_INTERVAL to work in a following way:
But reading the comment I think you want it to be set explicitly to Lazy loadingAbout lazy loading, I think it should be the standard, I do not see the value of boot then crash if no configuration. I Agree with @MarkCheshire ErrorsIf loading a configuration leads to an error Summary
My 2 💵 |
@MarkCheshire @hallelujah RHAMP-10 describes that APIcast should crash when it can't get config. That is initial requirement that came from debugging hard to reproduce network errors. I definitely want my service to crash, when it gets invalid config. I think @3scale/operations could have opinion on this too. Loading the configuration on boot from the remote API is quite consistent with giving it configuration in a config file. It would also be loaded on boot and crash when invalid or missing. Imo the semantics of lazy loading are defined like: start with empty configuration, load configuration on demand by host. Where the common scenario for any stable environment is: start with this configuration. I think preloading the configuration is maybe a better term than |
Yes, a server that is started with a missing or invalid config - should fail health checks made to it - whether any client requests are made to it or not. |
I guess that settles that preloading configuration is a requirement. Here is my proposal for configuration reloading failures (both modes): When
For
For
Will be updating Concurrency section in the description. |
@hallelujah re the values of auto update. The default should be the most stable production mode. That would mean cache forever. I guess the empty value could mean |
Some questions/comments:
Also, I'd prefer to have a way to "force" configuration reload rather than making it all automatic (and wait for the TTL until the conf is applied to test if all is OK). For example, extend the |
Yes auto-reload every N is going to download the configuration and apply it. The idea is that the http_ng client will act as http cache, so it will just return cached configuration in case it did not change (which is going to be ensured by Last-Modified and ETag headers). That whole part would be pushed to the the HTTP layer where it belongs. I guess you are afraid what happens between the time when the configuration expires and between new is downloaded. Lets go through the scenarios:
To answer your points:
You can force configuration reload by signalling nginx to reload for example. Why would you need to reload the configuration? There are options to do all of the options right now:
For self-managed apicast you can totally go with self reloading. Or by forcing the reload by |
OK I understand! Thanks. |
@hallelujah what is unintuitive? The default configuration should be as stable and production ready as possible that means no reloading and load configuration when starting or crash. That is the default. |
Well it is just a dev thought, nothing really bad. I meant empty == |
Update: decided that for on prem we want the following behaviour:
(this will allow us not to have to save config to staging env and promote to production env but let the customer save the first config to ) |
There are several ways how we want to load, store and expire configuration in different scenarios.
The main use cases are:
load configuration on boot, crash otherwise
Known as the production mode. Configuration is loaded only on boot and not reloaded.
load configuration on demand and reload on every request
Known as the staging mode. Every requests downloads new configuration, that is used
only for that request. Does not load configuration on boot because it would be immediately reloaded on first request. It can either load whole configuration or just for one host. (Per request configuration store #224)
load configuration on boot, reload every N seconds
Known as the production mode. Every N seconds after boot, new configuration should be downloaded and applied.
load configuration on demand, expire it after N seconds
Known as cloud mode. Does not get configuration on boot, but only on demand for one host.
Every configuration expires after N seconds and can be loaded on demand later again. (Store configuration with TTL #229)
The points 4 and possibly 2 need to pass host to the API call to get the configuration.
Point 3 needs to define what to do when configuration can't be downloaded.
Right now there are 3 flags that control this behaviour:
APICAST_RELOAD_CONFIG
that reloads config on every requestAPICAST_MISSING_CONFIGURATION
that controls what to do on missing configuration (exit,log)AUTO_UPDATE_INTERVAL
that controls how often to reload config in the backgroundI'd like to unify this to one max two configuration options. There are some incompatibilities between some methods like:
Proposal
Change AUTO_UPDATE_INTERVAL to work in a following way:
-1
- no auto reload, all configuration is persisted until restart0
- no cache, configuration is reloaded on every requestN
- expire/reload record in N secondsThis variable would be used in all the use cases to control how often configuration is reloaded.
Introduce APICAST_CONFIGURATION (proposals for different name welcome) with following options:
boot
- requires configuration on boot or crasheslazy
- download configuration on demand for each hostPlease note that
boot
should crash on missing, not empty configuration.Missing configuration can be when it fails to connect to the MT server and
empty is when it can connect but fetches 0 services.
Verification
-1
+boot
- load on boot or crash, cache forever0
+lazy
- load on demand, cache for one requestN
+boot
- load on boot or crash, cache for N (undefined behaviour on config reload)N
+lazy
- load on demand, cache for N (undefined behaviour after expiration)TODO
lazy
mode (put the stale record back, just remove the configuration, retry next time, ...)boot
mode (keep the stale record, remove, retry, ...)Concurrency and cache miss
In lazy loading we need to take care of concurrent loading of the same configuration for several requests in parallel.
There should be only one request to get configuration for one host at the same time.
There can be several requests for distinct hosts at the same time.
We probably should define this cross worker via shared memory lock and not just in one worker via a semaphore.
When there is a cache miss and configuration has to be loaded, for the interval between the first request comes and configuration is loaded, every request would trigger loading.
To limit number of concurrent loading configurations we have to wait for one inside the worker by using a semaphore and across workers using shared memory lock.
Changes
This changes several behaviours from 2.0:
The text was updated successfully, but these errors were encountered: