Hi,
We have been looking into environment caching and have some thoughts and ideas about how this can be done. Love to get your input on those ideas, and your thoughts about their usefulness.
There is a google document that has the long story - it is open for commenting. It is not required reading as the essence is outlined here.
The doc is here: https://docs.google.com/a/puppetlabs.com/document/d/1G-4Z6vi6Tv5xZtzVh7aT2zNWbOxJ3BGfJu31pAHxS7g/edit?disco=AAAAAGtMYOI#heading=h.rpgaxghcfqol
The current state of caching environments
---
A legacy environment caches the result or parsing manifests and loading functions / types, and reacts to changed files. It does this by recording the mtime of each file as it is parsed / read. Later, if the same file would be parsed again, it will use the already cached produced result. If the file is stale, the entire cache is cleared and it starts from scratch.
It does not however react to added files. It also does not recognize changes in files evaluated as a consequence of evaluating ruby logic (i.e. if a function, type, etc. required something, that is not recorded).
The new directory based environments does not support caching. (And now we want to address this).
The problem with caching
---
The problem with caching is that it can be quite costly to compute and we found that different scenarios benefits from different caching strategies.
In an environment where the ratio of modules/manifests present in the environment vs. the number actually used per individual node is low checking caching can be slower than starting with a clean slate every time.
- henrik
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/lj42jj%24b59%241%40ger.gmane.org.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/535668D8.4080902%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/d/optout.
We think there is a core set of strategies that a user should be able to
select. These should cover the typical usage scenarios.
* NONE - no caching, each catalog product starts with a clean slate.
This is the current state of directory based environments,
and it
could also be made to apply to legacy environments. This is good in
a very dynamic environment / development or low "signal/noise" ratio.
* REBOOT - (the opposite of NONE) - cache everything, never check for
changes. A reboot of the master is required for it to react to
changes.
This is good for a static configuration, and where the organization
always takes down the master for other reasons when there are changes.
This strategy avoids scanning, and is thus a speed improvement for
configurations with a large set of files.
* TIMEOUT - cache all environments with a 'time to live' (TTL). When a
request is made for an environment where the TTL has expired it
starts that environment with a clean slate.
This is a compromise - it will pick up all changes (even additions),
but it will take one "TTL" before they are picked up (say 5 minutes;
configurable).
These three schemes are believed to cover the different usage scenarios.
They all have the benefit that they do not require watching any files
(thereby drastically reducing the number of stat calls).
Strategy that is probably not needed:
* ENVDIRCHANGE - watches the directory that represents
the environment. Reloads if the directory itself is stale (using
filetimeout setting to cap the number of times it checks). Thus, it
will reaact to changes to the environment root only (which typically
does not happen when changing content in the environment, but is
triggered if the environments configuration file is added or removed).
To pick up any other changes, the user would need to touch the
directory.
Strategies we think are not needed:
* SCAN - like today where every file is watched.
* CONFCHANGE - watch/scan all configuration files.
Feedback ?
---
Here are a couple of questions to start with...
* What do you think of the proposed strategies?
* If you like the scanning strategy, what use cases do you see it would
benefit that the proposed strategies does not handle?
* Any other ideas?
* Any use cases you feel strongly about? Scenarios we need to consider...
On Monday, April 21, 2014 4:29:23 PM UTC-5, henrik lindberg wrote:
[...]We think there is a core set of strategies that a user should be able to
select. These should cover the typical usage scenarios.
* NONE - no caching, each catalog product starts with a clean slate.
This is the current state of directory based environments,
Is that why a user is reporting over on puppet-users that turning on directory environments explodes his catalog compilation times?
I don't see any reason to object to this strategy, but I'm inclined to doubt that many sites will find it useful in production.
and it
could also be made to apply to legacy environments. This is good in
a very dynamic environment / development or low "signal/noise" ratio.
* REBOOT - (the opposite of NONE) - cache everything, never check for
changes. A reboot of the master is required for it to react to
changes.
This is good for a static configuration, and where the organization
always takes down the master for other reasons when there are changes.
This strategy avoids scanning, and is thus a speed improvement for
configurations with a large set of files.
I could see the REBOOT strategy being used at very sensitive or tightly-controlled sites, but I'm inclined to think that ENVDIRCHANGE would be preferable to many people on account of the ability it affords to trigger cache invalidation without restarting the master.
* TIMEOUT - cache all environments with a 'time to live' (TTL). When a
request is made for an environment where the TTL has expired it
starts that environment with a clean slate.
This is a compromise - it will pick up all changes (even additions),
but it will take one "TTL" before they are picked up (say 5 minutes;
configurable).
That one makes me very nervous. It seems like an open invitation for manifest version shear. I would not even consider using it, myself; I'd prefer even scanning.
These three schemes are believed to cover the different usage scenarios.
They all have the benefit that they do not require watching any files
(thereby drastically reducing the number of stat calls).
Strategy that is probably not needed:
* ENVDIRCHANGE - watches the directory that represents
the environment. Reloads if the directory itself is stale (using
filetimeout setting to cap the number of times it checks). Thus, it
will reaact to changes to the environment root only (which typically
does not happen when changing content in the environment, but is
triggered if the environments configuration file is added or removed).
To pick up any other changes, the user would need to touch the
directory.
Perhaps it's unneeded, but that's the option I like best among those presented. I like having a means to manually flush the cache without restarting the master(s).
Strategies we think are not needed:
* SCAN - like today where every file is watched.
* CONFCHANGE - watch/scan all configuration files.
Feedback ?
I'm all for moving away from the SCAN approach. As for CONFCHANGE, is the idea basically a more clueful variant of ENVDIRCHANGE? I could imagine that being of interest, but if you're looking to streamline initial rollout then I could see deferring it until you can document demand for it.
---
Here are a couple of questions to start with...
* What do you think of the proposed strategies?
See above.
* If you like the scanning strategy, what use cases do you see it would
benefit that the proposed strategies does not handle?
Relative to scanning, they all make it a little harder to use an approach where the master automatically pulls manifests from VCS.
* Any other ideas?
Can the catalog compiler be induced to abandon its progress and restart the current catalog when the cache for its environment is flushed? That might make the TIMEOUT strategy more palatable, and it would be appropriate for some other strategies, too.
* Any use cases you feel strongly about? Scenarios we need to consider...
If I'm actively changing the manifest set on my master, then I know better than the master when I've done, and I favor being able to hold off on flushing the cache until then. Also, I like being able to flush the cache of just one environment at a time, and without bringing down the master to do so.
John
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/a80a3c7c-99cd-44ed-aef3-36eaf481604e%40googlegroups.com.
The problem with doing the manual cache invalidation is knowing which
running instance of the master to talk to
, and it would either need an
IPC mechanism, or that all instances watch the same file - and then we
are back at the complex behavior we want to avoid...
On Tue, Apr 22, 2014 at 1:32 PM, John Bollinger <john.bo...@stjude.org> wrote:
I could see the REBOOT strategy being used at very sensitive or tightly-controlled sites, but I'm inclined to think that ENVDIRCHANGE would be preferable to many people on account of the ability it affords to trigger cache invalidation without restarting the master.
Or in more performance oriented sites? It would reduce the number of stat calls that the master ends up doing. The thinking for this one was that in a production environment the master only should reread when the manifests have changed and that should be explicit. This can be done by signaling a graceful restart of the master for either passenger + apache or nginx + unicorn. For the apache setup it just takes sending a HUP to apache and for the nginx setup it takes sending a HUP to unicorn. I think that should provide a better deployment scenario for masters, but I might be wrong.
* ENVDIRCHANGE - watches the directory that represents
the environment. Reloads if the directory itself is stale (using
filetimeout setting to cap the number of times it checks). [...]
Perhaps it's unneeded, but that's the option I like best among those presented. I like having a means to manually flush the cache without restarting the master(s).
Wouldn't a graceful restart work just as well. I like the REBOOT + graceful restart option because it keeps the behavior of puppet much simpler and under the control of the user.
On Wed, 2014-04-23 at 03:19 +0200, Henrik Lindberg wrote:That should work for Apache or Nginx.
> On 2014-22-04 8:06, Thomas Hallgren wrote:
> > Would a MANUAL strategy make sense? I.e. instead of rebooting the
> > master, just tell it to clear the cache (perhaps per environment).
> >
> > - thomas
> >
> Circling back to this. Andy pointed out later that the best way to do
> this is to get the web environment to do a graceful restart by either
> sending apache or unicorn (depending on what is used) a HUP.
But what about the new users running a master on webrick?
Those are the users that we want to protect against:
* stale cache and endless issues to understand why the master doesn't
pick up the manifests changes
* bad performance if there's no caching at all. People are prompt to
make opinions (especially when something doesn't work at first).
But maybe, we just don't care about webrick (I don't remember if the
webrick support will abandoned or not or is it already)?
> The problem with doing the manual cache invalidation is knowing whichWell, having at most a dozen processes watching one given file shouldn't
> running instance of the master to talk to, and it would either need an
> IPC mechanism, or that all instances watch the same file - and then we
> are back at the complex behavior we want to avoid...
be as harmfull than having a dozen processes watching a ton of manifest
files...
--
Brice Figureau
My Blog: http://www.masterzen.fr/
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/1398685885.26219.32.camel%40arsenic.daysofwonder.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/CANhgQXszc%2BdN8Qj0QXVzBc%3D8WrAoL0KTwoSv2%3DEyxXKLWdQaXA%40mail.gmail.com.
If the per environment option is used, I'd like to see an associated puppet option to go with it.The others don't interest me all that much in general.I also like the NONE option since, as was pointed out, dev/test environments shouldn't be caching.The more I read all of this, the more I'm a fan of a MANUAL mode.A file per environment $ENV_HEAD/clear_cache or something that, when touched, will cause the cache to clear for that environment.
# Clear the 'production' environment cachepuppet cache clear# Clear the 'test' environment cachepuppet cache clear --env='test'
On Tuesday, April 22, 2014 6:41:18 AM UTC-7, Trevor Vaughan wrote:The more I read all of this, the more I'm a fan of a MANUAL mode.
A file per environment $ENV_HEAD/clear_cache or something that, when touched, will cause the cache to clear for that environment.
If the per environment option is used, I'd like to see an associated puppet option to go with it.I also like the NONE option since, as was pointed out, dev/test environments shouldn't be caching.The others don't interest me all that much in general.
# Clear the 'production' environment cachepuppet cache clear# Clear the 'test' environment cachepuppet cache clear --env='test'
something like that could also be used with the source control system when something gets deployed to refreshed the environment once things are "updated" (svn up && puppet env refresh or whatever)...
if someone is just starting, just have a way to disable caching altogether, so you can quickly iterate on your 3 test machines + puppetmaster, and those of us who have large scale puppet masters can use that mechanism when we deploy new modules/config for puppet.I'd like to have both clear specific env cache, as well as "clear everything" (although, i would think a "clear all caches" would be sufficient at first,...my $0.02Jok
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/45883229-eaac-42ba-9c5b-15cb886924b1%40googlegroups.com.
So 3.6.0-rc1 is out but the new caching mechanism seems pretty much useless to me without a face or method to invalidate that cache (restarting the Puppetmaster is not a good method unless there's some one to do it with a SIGHUP or USR1/2).
The only way I can see this working for most people is having a cache of unlimited and invalidating that cache at deploy time. I'm not very susceptible that 'long lived low traffic environments like production' can benefit from large cache times because when you roll out a change you want it now, not now + timeout.
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/f2bbcce2-f001-4170-a69a-9502b44e6d24%40googlegroups.com.
On Tuesday, April 22, 2014 8:19:57 PM UTC-5, henrik lindberg wrote:The problem with doing the manual cache invalidation is knowing which
running instance of the master to talk to
Why would you want to talk only to one? I can't think of a single reason. If you want to force a cache flush then want to do it for all instances of the master.
, and it would either need an
IPC mechanism, or that all instances watch the same file - and then we
are back at the complex behavior we want to avoid...
Well that's one of the advantages of ENVDIRCHANGE. All the instances watch the environment path directories for changes -- done. That's the directories themselves, not necessarily their contents. The whole cache goes stale, for each master instance, if the mtime of one of the environmentpath directories changes. I don't see how that yields anything nearly as complicated or quirky as the cache management approach available now.
If you wanted to provide a bit richer cache management feature set then the master could also watch the individual environment directories (again, the directories themselves) within the environment base directory. That could allow each environment's cache to be flushed independently.
A restart of the rack server takes time, during which Puppet would be unavailable. On a site afflicted with long catalog compilation times, or one where that master serves up large files, the restart could consume enough time to be a problem. Also, on a server that enforces fine-grained mandatory access controls it could be a much bigger deal to restart Puppet than just to touch a particular file.
John
John
--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/0327a530-82af-4bab-8c90-db844412843b%40googlegroups.com.