jquery

gist JS

Tuesday, February 16, 2016

Ruby on Rails on Docker on Amazon ECS w/ Terraform & DataDog

Buzzword buzzword buzzword.

But no seriously buzzword. This post is a followup to https://segment.com/blog/rebuilding-our-infrastructure/ which is a great post about how a real company is doing something awesome.

My real company (ezCater) is interested in doing awesome things too, but since a month ago I didn't really know how to plug a docker into a cloud I thought I'd start off simple with my smaller project whatsize.is ("So the gift always fits"  catchy right?)



As I said the Segment post is great, but it did leave a bit to the imagination and I'm a real literal fellow. So here comes the gritty details.


Dockerfile

Nothing too too amazing. But you can see we're also installing Traceview. And then, maybe not too gracefully working around Docker's inability to run > 1 thing by running start.sh and running 2 things in there. You would probably want to do supervisord if you were being smarter.


Terraform

Do you like the AWS UI?  Do you get a warm fuzzy feeling using a UI to click around and reconfigure your VPCs & ELBs?  I sure don't.  Never do that again. Terraform fixes this whole problem and makes me feel warm and fuzzy that I'm not going to end up with some bespoke AWS setup that I can no longer comprehend.

Check out rails-docker-ecs-datadog-traceview-terraform for an AWS setup that gets you:
  • ELB
  • ECS
  • VPC
  • Roles & Policies
  • DataDog agent running in a container on each of your instances
  • Traceview running next to your rails apps.
Do NOT blindly put ^ in production. I am bad at security and bad at AWS.  The above functions afaict. But I punched security & common decency in the nose a couple times.  


You don't realize how blind most devs are flying until you change companies and no longer have your opentsdb stack, your customer monitoring and alerting solution, your lisp-ish TSDB explorer, your custom Stats-On-The-TV service. Impressively DataDog seems to solve most all of this. You want instance metrics? Docker metrics? ELB metrics? RDS metrics? Custom metrics? Super customizable alerting? Seriously afaict it's game over and the Dawg won. You get a ridiculous amount for free out of the box. And with the setup above you have a statsd sink listening on udp:8125 that your app can kick any metric it wants to and instantly have it available in the Dawg.


Trace view is a lot like NewRelic, but has the advantage of being able to differentiate your ass from your elbow in the UI.  Seriously, look at this. 

Every single request you get a little blue mark.  Great you say, but get this! Drag a rectangle around them and you can slice into those requests, then for each of them you get a full freaking overview of just what happened in that request. Even the SQL. So freaking good.

Also fwiw if it sounds too good to be true or maybe it only works for my piddly little app I can verify that this also works at scale, with microservices.








That's all I've got. ECS is pretty awesome so far & something I feel decent taking a bet on, but it's definitely still young. The big todos left in this stack imho are:

  1. How do I run rake tasks from cron?
  2. Where do I get a rails console in prod?
  3. A deploy script to twiddle my ECS task versions.

Interested in making some of this real life? Come work with me! ezCater Jobs.