Regulate filesystem driver to max of 100 calls

It's easily possible for a flood of requests to trigger thousands of
concurrent file accesses on the storage driver. Each file I/O call creates
a new OS thread that is not reaped by the Golang runtime. By limiting it
to only 100 at a time we can effectively bound the number of OS threads
in use by the storage driver.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Signed-off-by: Tony Holdstock-Brown <tony@docker.com>
This commit is contained in:
Josh Hawn 2016-02-27 15:37:07 -08:00 committed by Tony Holdstock-Brown
parent 51972682c7
commit a88088a59d
2 changed files with 153 additions and 3 deletions

View file

@ -60,12 +60,12 @@ func FromParameters(parameters map[string]interface{}) *Driver {
// New constructs a new Driver with a given rootDirectory
func New(rootDirectory string) *Driver {
fsDriver := &driver{rootDirectory: rootDirectory}
return &Driver{
baseEmbed: baseEmbed{
Base: base.Base{
StorageDriver: &driver{
rootDirectory: rootDirectory,
},
StorageDriver: base.NewRegulator(fsDriver, 100),
},
},
}