Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Joy of single purpose services in Go

Joy of single purpose services in Go

What is Microservices?
Why use Microservices? and
Why Go (programming language) for Microservices?

Also, showcase how it worked for us and how we targeted certain part of our Ruby application and built with Go instead of replacing Ruby.

Transcription: https://sourcegraph.com/blog/live/gopherconindia/112656568167

#golang #GopherCon #microservices #ruby
https://twitter.com/nexneo

Niket Patel

February 20, 2015
Tweet

More Decks by Niket Patel

Other Decks in Programming

Transcript

  1. Ruby Ruby is simple in appearance, but is very complex

    inside, just like our human body. - Matz, ruby-talk (2000)
  2. This talk is about • How Microservices helped? • Why

    Go for Microservices? • “Use best tool for the job” applies to programming language as well.
  3. Major Problems with Our Ruby App • Memory consumption -

    some parts of application traded memory in hope for speed. • Speed - Ironically related to above
  4. General Ruby related problems • Ruby concurrency model revolves around

    multiple processes — Our app is particularly nasty with memory consumption. So, multi process concurrency is costly. • Ruby world moves quite faster then I would like. Things deprecates much faster.
  5. A new problem we created • We started new version

    of Beehively with goals for better UX and modern technology stack. • After few months of work we realized that we can't ask our customers to move to new system which has less features. (Second system effect)
  6. Triage • Better UX options. • Reduce memory problems. •

    Reduce cost if possible. • Bring new version of Beehively on par. 
 (and keep that way)
  7. Benefits of Pdf Service • Group reports generating at 12x

    speed • Reduced memory consumption by 30% • Accurate status tracking.
  8. Urgent alerts • This feature send emails, text(sms), voice calls

    as fast as possible. • Used rarely and by definition at some unpredictable time. • Concurrency cost (# of worker * ~400MB) • Tracking real time progress was nearly impossible (hint, more Memory)
  9. What is Alert Service? • Thin wrapper around our service

    providers. (twilio and mailgun) • 10, 30 or 60 workers costs just 5MB • Real time progress, accurate status as it happens. • We just need to ensure service remains up — No worries about # of alerts goes out same time.
  10. What is a Gradebook service? • It manages cache and

    calculation concerns of Gradebook • Simple LRU Cache, we got control over memory consumption. • By managing cache at correct level, we reduced invalidations. • Calculations were very fast, so I avoided caching results but just source data.
  11. Benefits of Gradebook service • We achieved 50x speed in

    some cases. • In most cases 10x speed up. • Controlled use of Memory for caching.
  12. Bonus Tip: React.js • We built Next gen Gradebook UI

    using React framework. • React is like Go, very simple to understand so you can concentrate on problem rather then pleasing framework/language.
  13. Fine print • We used nginx as router. • Redis

    as glue • Go service treat ruby application either as API client or proxy upstream.
  14. Deployments • Go deployments: build + rsync + upstart •

    Recently we started using amazon CodeDeploy. • Took couple of hours to ready Go App. • Ruby App it took 4 days (with several failed attempts)
  15. Conclusion • Main Application + Go Microservices is working beautifully.

    • We are not moving to Go from Ruby • We are adding Go
  16. Conclusion • Main Application + Go Microservices is working beautifully.

    • We are not moving to Go from Ruby • We are adding Go • Simple Deployments