<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Universe MrBlood</title>
    <description>The latest articles on DEV Community by Universe MrBlood (@ebaykann).</description>
    <link>https://dev.to/ebaykann</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F209172%2F222ef6ac-960f-4ce4-98ba-23d05af043d6.png</url>
      <title>DEV Community: Universe MrBlood</title>
      <link>https://dev.to/ebaykann</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ebaykann"/>
    <language>en</language>
    <item>
      <title>How we moved from Ruby to GO and decrease our cost by %1400  and increased response time by %500</title>
      <dc:creator>Universe MrBlood</dc:creator>
      <pubDate>Sat, 01 Aug 2020 11:26:54 +0000</pubDate>
      <link>https://dev.to/ebaykann/how-we-moved-from-ruby-to-go-and-decrease-our-cost-by-1400-and-increased-response-time-by-500-2onj</link>
      <guid>https://dev.to/ebaykann/how-we-moved-from-ruby-to-go-and-decrease-our-cost-by-1400-and-increased-response-time-by-500-2onj</guid>
      <description>&lt;h3&gt;
  
  
  &lt;em&gt;As of today ( Aug 2019 ) it’s been more than 5 years since I wrote the first lines of the Insider’s Mobile suite.&lt;/em&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FXYttkNV%2Ffirstcommit.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FXYttkNV%2Ffirstcommit.png" title="Gool old first commit message" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I was a fresh graduate and I neither had the knowledge nor the experience to create big things was very limited. I was an iOS engineer, building applications that used parse.com (PaaS) and that was it. Without any knowledge of building a web application, the first challenge was picking the right platform that would stick with me for years of sleepless nights of developing new features and debugging problems ( basically coding :&amp;gt; ).&lt;/p&gt;

&lt;h4&gt;
  
  
  Criteria;
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;I was in need of developing with high velocity, so the learning curve of the language had to be  low&lt;/li&gt;
&lt;li&gt;The community. IMHO, the community is a crucial factor that’s being overlooked, there should be lots of content, docs, people that would help with your problems&lt;/li&gt;
&lt;li&gt;High availability of third party packages - a crucial item if you are building mvp that needs to go live, fast .&lt;/li&gt;
&lt;li&gt;A modern language that would get us a better talent pool, high caliber engineers (i’m not going to get into all that 10x engineer fight here) who stay at the edge of the technology &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With these criteria in mind, I decided to go with Ruby with Rails framework&lt;/p&gt;

&lt;p&gt;RoR was perfect for us to create new features since during the bootstrap phase, we needed to build almost a new feature / product per week.&lt;/p&gt;

&lt;p&gt;We were using capistrano to deploy and unicorn as the http server, devise to authenticate. &lt;/p&gt;

&lt;p&gt;For years, it served it purpose. But then..&lt;/p&gt;

&lt;h2&gt;
  
  
  PROBLEM:
&lt;/h2&gt;

&lt;p&gt;We had lots of publisher clients.&lt;br&gt;
This meant a flash news story would create an enormous traffic increase on our end.&lt;br&gt;
Which was causing our system to - roughly - per minute request counts can escalate from 30k to 400k in 10 seconds.&lt;/p&gt;

&lt;p&gt;This was an entirely different problem to solve.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ruby is not designed to handle applications that need high concurrency.  Rails model dictates that every request will use work process whereas processes represented and handled by unicorn workers. &lt;/li&gt;
&lt;li&gt;It was taking around 3 minutes for a new worker instance to scale up by an auto scale group and by the time it completed the operation, the system load would turn back to normal. It was just a waste of resources and valuable monetary resources.&lt;/li&gt;
&lt;li&gt;Ruby is not designed to be an asynchronous language. Sure there were lots of background workers ( rails 5’s native worker support wasnot even released back then)
*RoR was a complete memory hog. We had to write custom bash scripts that check the workers and kills them (than used &lt;a href="https://github.com/kzk/unicorn-worker-killer" rel="noopener noreferrer"&gt;https://github.com/kzk/unicorn-worker-killer&lt;/a&gt;  for literally the same purpose) &lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Short Term Bullets that failed :
&lt;/h3&gt;

&lt;p&gt;We applied lots of patches to handle this problem, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pooling requests coming from SDK to minimize the number of requests that hit the Load Balancer, which was creating a data delay - not good&lt;/li&gt;
&lt;li&gt;Scale up the auto scale group BEFORE the pushes delivered to the end user RIGHT after creating a campaign, which had lots of false positive means burning money and for a new worker node to become available was already taking too long for this approach&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  &lt;em&gt;&lt;em&gt;At that point, we knew that we had to leave RoR behind.&lt;/em&gt;&lt;/em&gt;
&lt;/h4&gt;
&lt;h6&gt;
  
  
  &lt;em&gt;&lt;em&gt;We had to find the right tool for this job, where we needed a new language that is async by design.&lt;/em&gt;&lt;/em&gt;
&lt;/h6&gt;
&lt;h2&gt;
  
  
  Solution:
&lt;/h2&gt;

&lt;p&gt;After weeks of research and quick benchmark tests we decided to re-write our APIs in GO &lt;/p&gt;

&lt;p&gt;This marked the start of a new era for both our APIs and our wallets. &lt;/p&gt;

&lt;p&gt;After months, RoR codebase was filled with monkey patches. A rewrite would mean a clean slate, free of the patches that were making the codebase almost unreadable and unmaintainable &lt;/p&gt;

&lt;p&gt;The first iteration of API was not testable and didn’t include any unit tests , the chance of implementing a test driven development was great&lt;/p&gt;

&lt;p&gt;Speed; HOLLY COW. even the most basic operation performance difference is insane which was exhilarating for us which will enable us to create state of the art applications &lt;/p&gt;
&lt;h3&gt;
  
  
  A short example
&lt;/h3&gt;

&lt;p&gt;Ruby&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100_000_000&lt;/span&gt;
&lt;span class="no"&gt;Benchmark&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bm&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;bm&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="n"&gt;bm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'filling array'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;
      &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt;  &lt;span class="s2"&gt;" array size: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;size&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;


  &lt;span class="n"&gt;bm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;report&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'iterating array'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
      &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
    &lt;span class="nb"&gt;puts&lt;/span&gt;  &lt;span class="s2"&gt;" sum of numbers in array: &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;size&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;100000000&lt;/span&gt;
&lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="n"&gt;fillingArrayStarter&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;size&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"array size: %d took: %s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numbers&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Since&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fillingArrayStarter&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


&lt;span class="n"&gt;iterationStarter&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;var&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;numbers&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;counter&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Printf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;sum of numbers in array: %d took: %s"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;counter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Since&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;iterationStarter&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;




&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FsvWgJv9%2Fgovsruby.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FsvWgJv9%2Fgovsruby.png" title="go vs ruby" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initializing an array and filling it with 10 million incremental number&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Ruby&lt;/th&gt;
&lt;th&gt;Go&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;8.426792 s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;382.182509 ms&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Go is &lt;strong&gt;22x&lt;/strong&gt; faster&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Iterating the filled array and getting the sum of all the numbers&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Ruby&lt;/th&gt;
&lt;th&gt;Go&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;4.686981 s&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;91.622391 ms&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Go is &lt;strong&gt;51x&lt;/strong&gt; faster&lt;/p&gt;

&lt;h2&gt;
  
  
  Rewrite Process
&lt;/h2&gt;

&lt;p&gt;We chose our first api to re-write and started the process.&lt;/p&gt;

&lt;h3&gt;
  
  
  First impressions
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;RoR has a built-in ORM called ActiveRecord that comes with schema migrations and these migrations were absolutely amazing to dynamically add new columns, maintain multiple dev environments without even breaking a sweat
#### example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="ss"&gt;:migrate&lt;/span&gt; &lt;span class="c1"&gt;# runs (single) migrations that have not run yet.&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="ss"&gt;:create&lt;/span&gt; &lt;span class="c1"&gt;# creates the database&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="ss"&gt;:drop&lt;/span&gt; &lt;span class="c1"&gt;# deletes the database&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="ss"&gt;:schema&lt;/span&gt; &lt;span class="c1"&gt;#:load creates tables and columns within the (existing) database following schema.rb&lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="ss"&gt;:setup&lt;/span&gt; &lt;span class="c1"&gt;# does db:create , db:schema :load, db:seed &lt;/span&gt;
&lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="ss"&gt;:reset&lt;/span&gt; &lt;span class="c1"&gt;# does db:drop, db:setup&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For go, we needed to maintain our own structures with custom scripts and custom structures, which was hard to adopt at the beginning. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;GO is &lt;strong&gt;DEFINITELY&lt;/strong&gt; not magical, which makes it 

&lt;ul&gt;
&lt;li&gt;easy to read&lt;/li&gt;
&lt;li&gt;easy to maintain&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let me elaborate; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FCsbCfhR%2Fmagicalarrays.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.ibb.co%2FCsbCfhR%2Fmagicalarrays.png" title="Too magical!" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in this screenshot, a simple initialized array of integers has 10s of functions by default ! &lt;/p&gt;

&lt;p&gt;In  GO world, the only magic is how fast it is. You even have to implement the &lt;em&gt;unique&lt;/em&gt; function yourself &lt;/p&gt;

&lt;p&gt;### Example function to get&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;uniq&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;intSlice&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;map&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt; 
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;intSlice&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt;
            &lt;span class="n"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;list&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;    
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;list&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bright side of this lack of magicalness; you will never ever be surprised by your code. Everything is in your hand, and your hands alone&lt;/p&gt;

&lt;p&gt;Down side, the road of transition from ruby to go means lots of writing utility functions.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Deployment is unbelievably easy on go. You just run

&lt;code&gt;go build&lt;/code&gt;

and that's it. You will have an executable file which contains all of your source is and packages as compiled.
And again, it has a cross compiler by default as well
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GOOS=linux GOARCH=amd64 go build
GOOS=windows GOARCH=amd64 go build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;As I stated in the problematic part of rails, for a new docker app to be come available, unicorn workers needs to be initialized, which was taking around 3 minutes. In the Go World, the application was able to become ready to handle traffic in a couple of seconds which was crucial in the need of scale up.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Endgame
&lt;/h2&gt;

&lt;p&gt;The results were better than we anticipated.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Before GO &lt;br&gt;
we had (on average) 14 c5.xlarge (8 CPU / 16 GB Mem) instances and on each major push campaign (where the request count was increasing by %300 in seconds) we had huge outages and latency issues on all of our API's.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;After Go&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;14 c5.xlarge&lt;/strong&gt; decreased to &lt;strong&gt;2 c5.large&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;the number of needed scale up wasn't any need to scale up since the average execution time were also decreased dramatically &lt;/li&gt;
&lt;li&gt;the system was written with unit tests which enabled us to adopt CI and decreased our bug ratio per sprint by around %5 percent per quarter&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - It was SUPER FUN.
&lt;/h2&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Credit:
&lt;/h3&gt;

&lt;p&gt;I'd also like to thank my very good friend and coworker Cem Sancak for introducing us to the amazing world of GO and be one of the frontiers of these transitions. &lt;/p&gt;

</description>
      <category>rails</category>
      <category>ruby</category>
      <category>go</category>
      <category>tdd</category>
    </item>
  </channel>
</rss>
