Skip to content

Instantly share code, notes, and snippets.

View joshrendek's full-sized avatar

Josh Rendek joshrendek

View GitHub Profile
@joshrendek
joshrendek / kube-registry.yaml
Created June 6, 2018 14:24 — forked from coco98/kube-registry.yaml
Docker registry on minikube
apiVersion: v1
kind: ReplicationController
metadata:
name: kube-registry-v0
namespace: kube-system
labels:
k8s-app: kube-registry
version: v0
spec:
replicas: 1
@joshrendek
joshrendek / 2013-01-07-profiling-memory-leaky-sidekiq-applications-with-ruby-2.1.md
Created March 22, 2016 19:01
Profiling memory leaky Sidekiq applications with Ruby 2.1

My largest Sidekiq application had a memory leak and I was able to find and fix it in just few hours spent on analyzing Ruby's heap. In this post I'll show my profiling setup.

As you might know Ruby 2.1 introduced a few great changes to ObjectSpace, so now it's much easier to find a line of code that is allocating too many objects. Here is great post explaining how it's working.

I was too lazy to set up some seeding and run it locally, so I checked that test suite passes when profiling is enabled and pushed debugging to production. Production environment also suited me better since my jobs data can't be fully random generated.

So, in order to profile your worker, add this to your Sidekiq configuration:

if ENV["PROFILE"]
Insert the following code into the *.VMX file:
sched.mem.pshare.enable = "FALSE"
mainMem.useNamedFile = "FALSE"
prefvmx.minVmMemPct = "100"
prefvmx.useRecommendedLockedMemSize = "TRUE"
mainMem.partialLazySave = "FALSE"
mainMem.partialLazyRestore = "FALSE"
priority.grabbed = "high"
priority.ungrabbed = "normal"
<?xml version="1.0" encoding="UTF-8"?>
<hosts>
<host>
<name>ota-db1</name>
<dell_service_tag>ASDVB</dell_service_tag>
<make_model>Dell PowerEdge R610</make_model>
<os>
<os_name>CentOS x86_64</os_name>
<os_version>5.2</os_version>
</os>