<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Performance on vnykmshr</title><link>https://blog.vnykmshr.com/writing/tags/performance/</link><description>Recent content in Performance on vnykmshr</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 18 May 2017 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.vnykmshr.com/writing/tags/performance/index.xml" rel="self" type="application/rss+xml"/><item><title>Nginx load balancing decisions</title><link>https://blog.vnykmshr.com/writing/nginx-load-balancing/</link><pubDate>Thu, 18 May 2017 00:00:00 +0000</pubDate><guid>https://blog.vnykmshr.com/writing/nginx-load-balancing/</guid><description>&lt;p&gt;Nginx as a reverse proxy and load balancer is well-documented. The configuration syntax is not the hard part. The decisions are.&lt;/p&gt;
&lt;h2 id="algorithm-selection"&gt;Algorithm selection&lt;/h2&gt;
&lt;p&gt;Three algorithms cover most workloads.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Round-robin&lt;/strong&gt; (the default). Requests cycle through backends sequentially. Weights let you bias toward higher-capacity servers. Simple, predictable, works well when request processing times are uniform.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-nginx" data-lang="nginx"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;upstream&lt;/span&gt; &lt;span class="s"&gt;api&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kn"&gt;server&lt;/span&gt; &lt;span class="n"&gt;api-01&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="s"&gt;weight=3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kn"&gt;server&lt;/span&gt; &lt;span class="n"&gt;api-02&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="s"&gt;weight=2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kn"&gt;server&lt;/span&gt; &lt;span class="n"&gt;api-03&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;8080&lt;/span&gt; &lt;span class="s"&gt;weight=1&lt;/span&gt; &lt;span class="s"&gt;backup&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kn"&gt;keepalive&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;backup&lt;/code&gt; directive keeps a server in reserve &amp;ndash; it only receives traffic when all non-backup servers are down. Useful for a smaller instance that can keep the service alive during a partial outage but shouldn&amp;rsquo;t take production load normally.&lt;/p&gt;</description></item><item><title>Switching to Go</title><link>https://blog.vnykmshr.com/writing/switching-to-go/</link><pubDate>Wed, 07 Dec 2016 00:00:00 +0000</pubDate><guid>https://blog.vnykmshr.com/writing/switching-to-go/</guid><description>&lt;p&gt;I&amp;rsquo;d been building production services with Node.js since 2013. Custom blog engines, API services, real-time backends. The ecosystem was rich, iteration was fast, and for moderate-load services, it worked well.&lt;/p&gt;
&lt;p&gt;The limits showed up at scale. A latency-sensitive payment processing API exposed three problems that were manageable at lower traffic but compounded at higher volumes.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;GC pauses.&lt;/strong&gt; Node&amp;rsquo;s garbage collector introduced latency spikes that were unpredictable and hard to tune. For payment processing, where consistent response times matter more than peak throughput, this was the biggest concern. A p99 spike during a GC pause means a user staring at a spinner while their payment hangs.&lt;/p&gt;</description></item></channel></rss>