GKE is an awesome service provided by Google which allows you to easily setup a fully managed Kubernetes cluster. The one downside is that the price structure can be fairly confusing and you can spend lots of money without knowing it. Below are a couple tips I’ve learned which will help you cut down on your GKE bill!

Ingress over Load Balancer

One of the biggest money saving is by using an Ingress instead of Load Balancer. If you have 5 microservices and each has it’s own load balancer the price gets pretty crazy. Using an ingress will reduce the price because you can have multiple services be exposed by a single load balancer by giving them routing rules. So, If you’re planning on having more then a couple of microservices, this cost is going to start adding up when strictly using load balancers, and it doesn’t make a lot of sense to be paying more for your load balancing then your Compute Instances!

Reverse Proxies

Using a reverse proxy can be useful in greatly decreasing your GKE bill. A reverse proxy will reduce the number of ingress rules by adding a small bit of routing logic to a container. A great example of how to create a reverse proxy with Nginx is here. You can also use something like HAProxy if you need extra performance. A general overview of how it would work is you have a proxy container running Nginx or HAProxy which contains instructions to route certain paths to different microservices.

/auth ---> http://auth-service.prod
/search ---> http://search-service.prod

Cost Calculator

One of the best ways to reduce cost of GKE is to use the cost calculator Google provides. With this tool you can price out exactly how much your infrastructure is going to cost in advance and make tweaks to optimize performance. This is most useful when provisioning servers because different configurations can give you better prices depending on your needs.

Committed Usage

The easiest way to save money is by committing to using a certain amount of resources for an extended amount of time. Obviously there is some risk to this because you are committing for between 1 and 3 years, but the discounts are very good!

1 Year

CPU is 11% cheaper per vCPU month

Ram is 11% cheaper per GB month

3 Years

CPU is 55.5% cheaper per vCPU month

Ram is 55.5% cheaper per GB month

Hope these tips help you reduce your GKE bill! If I missed any techniques you use I’d love to hear about them in the comment section below.

Categories: Architectures

Leave a Reply

Your email address will not be published. Required fields are marked *