furan icon indicating copy to clipboard operation
furan copied to clipboard

Docker image cacheing support

Open DavidHuie opened this issue 7 years ago • 3 comments

In order to not have to manage the size of the Docker image volume, Furan currenly operates statelessly, deleting all images after each Docker image build. For Docker images with quick build speeds, this tends to work fine. However, at Dollar Shave Club, we have Docker image projects that can have slow Docker build processes and large base images. In practice, over 50% of the time spent building these specific Docker images can be saved with support for Docker image cacheing.

I propose that Furan implements support for Docker image cacheing by introducing an image garbage collection system. The image GC system will ensure that the Docker image volume used by Furan doesn't grow incessantly, while also ensuring that the Docker image volume is always near capacity, enabling a high cache hit ratio.

In terms of implementation, image GC is already a solved problem. Kubernetes offers an implementation of Docker image GC since each Kubernetes worker (a "kubelet") is in charge of managing the Docker image volume on the host. I propose that we borrow this implementation in Furan.

The Kubernetes image GC implementation offers three parameters that give us the flexibility that we need:

type ImageGCPolicy struct {
	// Any usage above this threshold will always trigger garbage collection.
	// This is the highest usage we will allow.
	HighThresholdPercent int

	// Any usage below this threshold will never trigger garbage collection.
	// This is the lowest threshold we will try to garbage collect to.
	LowThresholdPercent int

	// Minimum age at which an image can be garbage collected.
	MinAge time.Duration
}

The implementation references certain Kubernetes tools and packages that are specific to Kubernetes, such as cAdvisor for metrics and the internal container runtime code. These tools could be reimplemented for the sake of image GC since the GC code only uses a subset of the supported operations.

DavidHuie avatar Sep 01 '17 18:09 DavidHuie

👍 I like it.

@DavidHuie Let's think about defaults and how we can provide a sane experience for users who naively upgrade without thinking specifically about GC settings.

bkeroackdsc avatar Sep 01 '17 19:09 bkeroackdsc

@bkeroackdsc we can definitely make this an optional feature, opting out by default.

DavidHuie avatar Sep 05 '17 18:09 DavidHuie

Looks good to me!

hankjacobs avatar Sep 05 '17 18:09 hankjacobs