How We Built Our Own Heroku

At Simpl, we faced a challenge to run a polyglot microservices based platform in auto-scalable and secure manner. We did not have dedicated DevOps person. We could not go ahead with a PaaS solution for lack of customizability. So we built our own solution called cloudlift. I and Jeechu presented this at multiple meetups.

Sharing the presentation here…

So, You Built Webhooks? And Wanna Test

When you build public facing APIs, there are operations that could not fit enough into request-response cycle. Especially, when it involves user interaction.

Take an example of sending email. You can expose an API endpoint for clients to send email. But whenever the email is opened, the client want to do some action. They can keep polling you and get the status of the email of course. But, that’s suboptimal on both sides. So you want to tell the client when the email is opened. Now, that’s when you do webhooks (ref).

Webhooks are easier to build. After all, it’s just one http call you will have to make.

But, testing it is not so.

VCR - Match Body

We had to have make external API calls and we used vcr to record and replay in our integration tests. All was going on well.

Despite this coverage, we saw our code breaking in production due to small chages in request xml body. We wanted our integration spec to cover these too. By default, vcr matches request method and url. We wanted it to match the post body too. Simple match by body does not solve as it does plain string match. It would give false negatives.

So, we decided to match our xml request body. This is what we did.

Apache Camel With Scala: Extending DSL

Let’s take a very simple use case of integrating with a http endpoint which has an authentication mechanism.

      //Do some processing
      .setHeader("Authorization", _ => "OAuth anObfuscatedTokenString")
      .setHeader(Exchange.HTTP_METHOD, "GET")
      .process(//Do something with response)

      //Do some processing
      .setHeader("Authorization", _ => "OAuth anObfuscatedTokenString")
      .setHeader(Exchange.HTTP_METHOD, "POST")
      .process(//Do something with response)

You can clearly see if have many routes like this, there will be a lot of duplication.

Apache Camel With Scala: Testing Styles

Scala with Camel is a very powerful combination for integration. Camel has fantastic support for testing. It’s very easy and useful to test-drive the integration. Following are few styles when it comes to testing camel with scala.

Integer.parseInt(‘God’) = ???

Migrated from: My old post

Today people visit temple for so many reasons. Fundamentally, those reasons come out of fear or greed depending on the situation. During recession people ask god to save job (out of fear) or otherwise, they ask for promotion or better job (out of greed).

How We Debugged Memory Leak in a Rails App.

We run our app on heroku and kept on getting R14s. Our google and stackoverflow skills did provide few suggestions and but din’t help much. We used few tools (rack_bug, oink) see the memory usage. They provided who use how much
but we could make further progress with that. So here’s what we did to find out.