<?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: Ben Rometsch</title>
    <description>The latest articles on DEV Community by Ben Rometsch (@dabeeeenster).</description>
    <link>https://dev.to/dabeeeenster</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%2F78279%2F0ca8c88e-ee88-4e3d-bcbd-9a3fa585535d.jpeg</url>
      <title>DEV Community: Ben Rometsch</title>
      <link>https://dev.to/dabeeeenster</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dabeeeenster"/>
    <language>en</language>
    <item>
      <title>The actual infrastructure costs of running SaaS at scale (billions of requests/month)</title>
      <dc:creator>Ben Rometsch</dc:creator>
      <pubDate>Tue, 17 May 2022 16:09:56 +0000</pubDate>
      <link>https://dev.to/dabeeeenster/the-actual-infrastructure-costs-of-running-saas-at-scale-billions-of-requestsmonth-5hlm</link>
      <guid>https://dev.to/dabeeeenster/the-actual-infrastructure-costs-of-running-saas-at-scale-billions-of-requestsmonth-5hlm</guid>
      <description>&lt;p&gt;In this article we are going to share two main things: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The evolution of our infrastructure over the last few years&lt;/li&gt;
&lt;li&gt;The actual costs of our SaaS offering at Flagsmith&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Before we dive in, one important call-out:&lt;/strong&gt; We provide our feature management product to customers in three ways depending on how they want to have it managed: Fully Managed SaaS API, Fully Managed Private Cloud SaaS API and Self-Hosted. The infrastructure costs that we are sharing is for our customers that leverage our Fully Managed SaaS API offering (try it free: &lt;a href="https://flagsmith.com/" rel="noopener noreferrer"&gt;https://flagsmith.com/&lt;/a&gt;) which represents a portion of the total flags being delivered among those three product offerings. &lt;/p&gt;

&lt;h2&gt;
  
  
  The Evolution (and costs) of our SaaS Infrastructure 
&lt;/h2&gt;

&lt;p&gt;Late last year, the Flagsmith SaaS API crossed the threshold of a billion flags served in one month. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9vti2wp85wryf6afc3n.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg9vti2wp85wryf6afc3n.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To help others learn from our mistakes and successes, we’re sharing how our infrastructure changed over this period, the money we spent, the choices we made, and why we made them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Infra Round 1: 2 hours of effort
&lt;/h2&gt;

&lt;p&gt;Flagsmith started as a side project of &lt;a href="https://solidstategroup.com/" rel="noopener noreferrer"&gt;Solid State Group&lt;/a&gt; - the agency I started 21(!) years ago. We had been building side projects for a while and had perfected the art of building as much as possible as quickly as possible. That meant leaning on frameworks like Django and Django Rest Framework to do as much heavy lifting as possible. But it also meant that our infrastructure was optimised for 2 things: 1) cost and 2) minimal effort to stand up. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznfqldt3jd2oc7u6vzjr.jpeg" 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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fznfqldt3jd2oc7u6vzjr.jpeg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you have zero customers, lean into that. &lt;/p&gt;

&lt;p&gt;We already had a Hetzner server kicking around that wasn’t doing much, so we installed &lt;a href="https://dokku.com/" rel="noopener noreferrer"&gt;dokku&lt;/a&gt;;  a great project that gives you a self-hosted Heroku-like deployment platform but with minimal costs. We set up a super simple CICD via GitLab CI that would push changes to our &lt;code&gt;main&lt;/code&gt; branch to dokku as we went. Postgres was up and running in 2 minutes. Sorting the DNS and LetsEncrypt SSL certificate was pretty easy. And that was it. Total time spent was maybe 2 hours. &lt;/p&gt;

&lt;h2&gt;
  
  
  Oh, actually now we have actual customers LOL
&lt;/h2&gt;

&lt;p&gt;Pretty soon after releasing the platform and trying to drum up some traffic, we noticed a huge increase in traffic to our API. Back then we were hacking Google Analytics to track our API volume - it was free which was basically 90% of the decision making process. After some further investigation we realised a fairly large UK lottery operator was using the platform on some highly trafficked pages. This was great: people are using our platform! but also terrifying: people are using our platform!&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcsjv8ir5xz995wmllsd0.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcsjv8ir5xz995wmllsd0.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We were super busy building out basic features at that point in time; we really didn't want to invest any further effort into our infrastructure. People don’t buy your infrastructure, they buy your product. But we had the problem; what we refer to as “the B2B2C problem”. &lt;/p&gt;

&lt;p&gt;It goes something like this. If we sign up a customer, and they put our JS SDK on their website, we aren’t serving that 1 customer; we are serving all of their customers. So 1 new person using our platform could mean suddenly serving 100 million additional flags a month. If you are direct B2C, your scaling looks way less crazy, as additional users come in one at a time. But if you are B2B2C, you might suddenly have to triple your requests served literally from one second to the next. &lt;/p&gt;

&lt;p&gt;And this is actually harder when you are small! When you are large, one large customer might mean an additional 10% load on your API, but when you are small, one large customer might mean 10x your load! It’s the power of small numbers. Or something. &lt;/p&gt;

&lt;p&gt;Anyway, once we saw this happening in real life we decided it was time to put our professional trousers on. Hetzner and dokku had been great, but it was making us super nervous. &lt;/p&gt;

&lt;h3&gt;
  
  
  Round 1 Wrap Up
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Total cost: ~$40 per month&lt;/li&gt;
&lt;li&gt;Peak Flags served per month: 20 million&lt;/li&gt;
&lt;li&gt;Anxiety Levels: 5/10 anxious but this all still feels like a side project&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Infra Round 2: 2 days of effort
&lt;/h2&gt;

&lt;p&gt;We know how to do this; we do it for our clients all the time! But in this case no-one was paying for it, so we wanted it to be clinically quick. We already had a Heroku-like deployment process. Elastic Beanstalk was pretty close to that, but with things like auto-scaling and managed databases; professional trousers stuff. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuvospfpocgxxhenh3yf.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnuvospfpocgxxhenh3yf.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So we went with AWS Beanstalk, EU London region (it was in the EU at the time #facepalm). It’s sort of in the middle of the world, and we care about latency a little. RDS Postgres works. It does automated backups and security updates.&lt;/p&gt;

&lt;p&gt;Beanstalk has loads of horrible sharp edges it turns out, but we plowed on and had things up and running in a couple of days. We stood up an Aurora Postgres database, and copied the data across. We had around 30 seconds of downtime where we finished migrating any new data, then pointed our Dokku instance over to AWS and updated our DNS records. Yes, we could have spent another month engineering a zero downtime migration, but these are the hard choices you have to make.&lt;/p&gt;

&lt;h2&gt;
  
  
  Elastic Beanstalk is actually great, but a bit terrifying
&lt;/h2&gt;

&lt;p&gt;We were actually surprised how far this setup got us. We only recently migrated off it, props to Beanstalk - it might be the most unloved AWS product there is, but it works and it’s stable. &lt;/p&gt;

&lt;p&gt;It does have a propensity, when you are doing something unusual like you &lt;em&gt;know, deploying your software&lt;/em&gt;, where it sort of gives up and then sits in a weird state for half an hour whilst you are crying, but it almost always righted itself and redeployments then worked. We never really got to the bottom of why this happened, but in almost all cases it didn’t drop any requests, which was rapidly becoming our most important consideration.&lt;/p&gt;

&lt;p&gt;Beanstalk also makes it super easy to scale out your application server layer. This worked perfectly, and was the main reason why we stayed on it for so long. At this point, the bottleneck of the platform started moving from the application server to the database and the number of connections it was having to service. At peak we got up to around 70 small app server instances. By this point our concurrent database connections were becoming our bottleneck.&lt;/p&gt;

&lt;h3&gt;
  
  
  Round 2 Wrap Up
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Total Cost: Elastic costing eh! Anything from $300 to $800 per month - Cloudfront is expensive and there’s nothing you can do about it&lt;/li&gt;
&lt;li&gt;Peak Flags Served per month: 600 million&lt;/li&gt;
&lt;li&gt;Anxiety Levels: Still high as hell during deployments but getting a text in the middle of the night is less stressful&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Infra Round 3: Containerisation Firecrackers
&lt;/h2&gt;

&lt;p&gt;Over time, Docker and the containerisation of everything meant that our production SaaS infrastructure was looking less and less like that of our Enterprise customers as time went by. We also realised that Beanstalk was basically on autopilot, and there were some python dependencies we really needed that weren’t available on the platform. &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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsjcd4qx7fvsymlkfak98.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsjcd4qx7fvsymlkfak98.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So we made the decision to move to AWS ECS and Fargate. We were already building &lt;a href="https://hub.docker.com/u/flagsmith" rel="noopener noreferrer"&gt;Docker images&lt;/a&gt; for our open source and Enterprise users, so it shouldn't be too tricky, right? By this time our application had grown to dozens of environment variables and the Beanstalk deployment had grown some hairballs here and there to kludge some stuff like SSL rewrites. &lt;/p&gt;

&lt;p&gt;Luckily we didn’t have to move the data, which is almost always the hard part. So we stood up a new ECS cluster and used the excellent support AWS load balancers provide for splitting traffic between our two different sets of infrastructure. Over the course of a couple of weeks we migrated 100% of the traffic over to ECS and the Beanstalk infra dropped away like a well used rocket first stage. &lt;/p&gt;

&lt;h2&gt;
  
  
  What do we think of ECS?
&lt;/h2&gt;

&lt;p&gt;ECS is superb and we love it a lot. &lt;/p&gt;

&lt;h3&gt;
  
  
  Round 3 Wrap Up
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Total Cost: Actually dropping on a $-per-request basis. We upgraded to python 3.10 and more modern gunicorn, and the Docker images are more performant than the Beanstalk infra. We are now spending around $1,200 per month which splits roughly evenly between RDS, ECS and Cloudfront/bandwidth.&lt;/li&gt;
&lt;li&gt;Peak Flags Served per month: Well into the billions&lt;/li&gt;
&lt;li&gt;Anxiety Levels: Actually pretty low. ECS is rock solid and has blue/green deployments built in. We’ve yet to get it into the fugue state that we often managed to with Beanstalk.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Infra Round 4: What’s next
&lt;/h2&gt;

&lt;p&gt;It’s coming up! We’re about to migrate our SDK traffic to a globally distributed and replicated Edge API. We’ve been working on it way too long but we’re going to deploy it very soon, and will be writing that up next! &lt;/p&gt;

&lt;p&gt;If you are curious about our performance, please &lt;a href="https://flagsmith.statuspage.io/" rel="noopener noreferrer"&gt;check out our status page&lt;/a&gt;. If you want to support us, &lt;a href="https://github.com/flagsmith/flagsmith" rel="noopener noreferrer"&gt;please give us a star on Github&lt;/a&gt;! If you need feature flags and want to partner with a team that is in it for the reasons I outlined above; feel free to &lt;a href="https://app.flagsmith.com/signup" rel="noopener noreferrer"&gt;sign up for a free&lt;/a&gt; account and give it a try! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=dQw4w9WgXcQ" rel="noopener noreferrer"&gt;Lets go&lt;/a&gt;!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My Mac Setup - 2020/21: Getting close to OS nirvana</title>
      <dc:creator>Ben Rometsch</dc:creator>
      <pubDate>Tue, 26 Jan 2021 14:15:32 +0000</pubDate>
      <link>https://dev.to/dabeeeenster/my-mac-setup-2020-21-getting-close-to-os-nirvana-202i</link>
      <guid>https://dev.to/dabeeeenster/my-mac-setup-2020-21-getting-close-to-os-nirvana-202i</guid>
      <description>&lt;p&gt;Here's how I set up my Mac. I feel like it's pretty close to the perfect setup for me. There are a couple of minor annoyances but the tools below really help with my flow and general good productivity vibes &lt;em&gt;cracks knuckles, drinks coffee, ends up reading Twitter for 10 minutes&lt;/em&gt;...&lt;/p&gt;

&lt;h2&gt;
  
  
  Clipboard Manager
&lt;/h2&gt;

&lt;p&gt;This is, without doubt, the biggest productivity booster and main contributor to overall feelings of time savings: working with the OS instead of fighting against it. &lt;br&gt;
It doesn't really matter which clipboard manager you use (I use the one built into &lt;a href="https://www.alfredapp.com/"&gt;Alfred&lt;/a&gt;) just so long as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It keeps a long history&lt;/li&gt;
&lt;li&gt;Is available with an easy keypress combo. I use CMD+Shift+v. &lt;/li&gt;
&lt;li&gt;It can store and display text and images&lt;/li&gt;
&lt;li&gt;It is searchable&lt;/li&gt;
&lt;li&gt;In Alfred  it shows the icon of the Application you were in when you copied the data to your clipboard, which helps find older entries&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are two main workflows I use the clipboard manager for. &lt;/p&gt;

&lt;p&gt;First is being able to search through a long history. URLs, images, code snippets I used yesterday. Being able to search through a few days of history feels like a superpower. I think I probably make use of this workflow about 50 times a day. &lt;/p&gt;

&lt;p&gt;Second is loading up several items of data into the clipboard in one app and then pasting them into another. Classic use-case for this is credit card data out of Bitwarden and into a web page. Similar for things like DB connection parameters. &lt;/p&gt;

&lt;h2&gt;
  
  
  Keyboard Based Window Manager
&lt;/h2&gt;

&lt;p&gt;I am totally in love with &lt;a href="http://www.hammerspoon.org/"&gt;Hammerspoon&lt;/a&gt;. Most people probably discover it as a window snapping tool but it is so much more than that. I have my Hyper key set up as Caps Lock via &lt;a href="https://karabiner-elements.pqrs.org/"&gt;Karabiner&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Hammerspoon helps you move windows around using keyboard shortcuts, but the API covers so much of OSX and related Apps, it really is selling it short to describe it like that. Here are some ways I use it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Snap windows to different parts of my screen&lt;/li&gt;
&lt;li&gt;Bounce windows between my MacBook and external screen&lt;/li&gt;
&lt;li&gt;Set up all windows for different work contexts (development/comms/reading browser etc.) in 1 shortcut&lt;/li&gt;
&lt;li&gt;Focusing on different windows with 1 shortcut. I can get to the 8 most used apps with single shortcuts like caps + i for iTerm. &lt;/li&gt;
&lt;li&gt;Changing MacBook desktop resolution for when I'm feeling old and don't need the high dpi. &lt;/li&gt;
&lt;li&gt;Running a Caffeine equivalent in my menu bar&lt;/li&gt;
&lt;li&gt;Changing sound output (Mac speakers/Jabra/Hifi)&lt;/li&gt;
&lt;li&gt;Play/Pause/Skip on Spotify&lt;/li&gt;
&lt;li&gt;Setting default volume in different contexts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Like I said, the API is great. You script Hammerspoon with Lua so you can pretend to be a game dev whilst you're at it. &lt;/p&gt;

&lt;h2&gt;
  
  
  Screenshot grabber
&lt;/h2&gt;

&lt;p&gt;Tried loads, settled on &lt;a href="https://zapier.com/zappy"&gt;Zappy&lt;/a&gt; from Zapier. Free, fast, does video, super easy to add annotations. Lightweight. Well done Zapier. &lt;/p&gt;

&lt;p&gt;Added the &lt;a href="https://github.com/tonyxu-io/Alfred-Workflow-Upload-S3"&gt;s3-image-upload Alfred&lt;/a&gt; plugin to Alfred so that I can share clipboard images online with one Alfred command, &lt;/p&gt;

&lt;h2&gt;
  
  
  Alfred / Launcher
&lt;/h2&gt;

&lt;p&gt;Alfred is very well known. Great software, I pay for upgrades as soon as they are available! My plugins:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a Gist from clipboard contents&lt;/li&gt;
&lt;li&gt;Create Calendly links&lt;/li&gt;
&lt;li&gt;Create Zoom links&lt;/li&gt;
&lt;li&gt;Upload clipboard to S3 and create public URL&lt;/li&gt;
&lt;li&gt;Search Obsidian&lt;/li&gt;
&lt;li&gt;Search Github Projects&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Infinite History
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/larkery/zsh-histdb"&gt;This is genius&lt;/a&gt;. Every single zsh command I've entered for the last ~9 months is stored in a sqlite database, instantly searchable. An amazing time saver for commands you run infrequently like obscure docker or gitlab-runner incantations. &lt;/p&gt;

&lt;h2&gt;
  
  
  ZSH tools
&lt;/h2&gt;

&lt;p&gt;I use &lt;a href="https://github.com/zimfw/zimfw"&gt;zimfw&lt;/a&gt; but I still feel like it takes too long to open a new terminal tab. I use the &lt;a href="https://github.com/romkatv/powerlevel10k"&gt;Powelevel10k&lt;/a&gt; theme which helps in that you can start typing as soon as a new tab is open but ZSH is not fully loaded, but it's still a delay. Still searching for a solution to this! &lt;/p&gt;

&lt;h2&gt;
  
  
  Dock
&lt;/h2&gt;

&lt;p&gt;I use this &lt;a href="https://www.amazon.co.uk/IVANKY-Docking-Station-Multiport-MacBook/dp/B089K8ZS2L"&gt;iVANKY&lt;/a&gt; dock. It's pretty good, but has a super weird bug when using Zoom where the network gets knocked out for a few minutes at a time. Super annoying! Zoom must be sending unusual traffic and I can't be bothered to figure out the root cause. Hoping it will go away in an OSX update at some point!&lt;/p&gt;

&lt;h2&gt;
  
  
  Best of breed apps
&lt;/h2&gt;

&lt;p&gt;I've settled on the following. These haven't changed all year, so I guess I like them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://tableplus.com/"&gt;Table Plus&lt;/a&gt;. Finally you can work with postgres databases with a beautiful app. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://paw.cloud/"&gt;Paw&lt;/a&gt;. Hands down the best REST GUI there is. The level of polish in Paw is just incredible. Plus they don't charge a regular fee for standard git style cloud storage. I love it so much. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.sublimemerge.com/"&gt;Sublime Merge&lt;/a&gt;. Fast as hell. I still end up in a git mess every now and then but at least I get there quickly.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://mimestream.com/"&gt;Mimestream&lt;/a&gt;. Gmail client. SEVEN MB. YES. SEVEN. Spiritual successor to Sparrow. Amazing. Love it. Would pay 200 dollars for a license when it comes out of beta without any hesitation. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.wireguard.com/install/"&gt;Wireguard&lt;/a&gt;. Worth the hype. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://bitwarden.com/"&gt;Bitwarden&lt;/a&gt;. I self host &lt;a href="https://github.com/dani-garcia/bitwarden_rs"&gt;bitwarden_rs&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
