 In this video series, we'll be using Pixie to estimate the cost of our Kubernetes services. In the last video, we estimated CPU cost. In this video, we'll estimate memory costs. And in future videos, we'll estimate network and amortized costs per request for each service. Okay, so what is Pixie? Pixie is an open-source observability tool for Kubernetes applications. Pixie uses EBPF to automatically collect a lot of data out of the box, such as infrastructure and network metrics, application profiles, and full-body requests. Pixie is a scriptable interface, so you can modify existing scripts or write custom scripts to do the analysis that you're interested in. In this video, we'll be writing a custom script to get visibility into the cost of our services. In this video, we're going to estimate memory cost. Memory cost can be calculated by multiplying the amount of time that memory has been used, times the number of gigabyte hours used, times the price per gigabyte hour. So here is Pixie's live UI. And from this HTTP service map, you can see all the microservices that are talking to each other. I'm going to open the scratchpad script, where I've got our custom memory cost script pasted into the editor. You can see that here. And we're just going to run the script using the Run button. This script outputs two tables. The top table shows estimated memory cost by service, and you can sort by cost. This top row shows the costs associated with pods that are not associated with a service. And then the bottom table sums the memory service costs into a total cost. Let's take a closer look at this script. So this script loads the last one hour of Pixie's process stats table into a data frame. The process stats table includes memory usage for all Kubernetes processes within your cluster. Memory is measured by UPD. So we take the average memory per UPD, since this value will fluctuate over the hour that we've measured it. Then we're going to sum the memory usage for all UPDs belonging to the service. Then we convert bytes to gigabytes. And now that we have the number of gigabyte hours, we're going to multiply by the gigabyte per hour price. And this price will depend upon your provider. We've chosen an estimated value, but you can try the script out yourself with your own value. And then finally we multiply this by the number of hours in a year in order to estimate the yearly cost. Now these scripts are all public, so you can try them out by following the link in the video description. If you want to play around with the script, it should be easy to modify it to slice the cost by pod or namespace. In the next video, we'll do a similar analysis for network usage, so be sure to check that out.