<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bart Verkoeijen on Medium]]></title>
        <description><![CDATA[Stories by Bart Verkoeijen on Medium]]></description>
        <link>https://medium.com/@bgever?source=rss-3f5cfc632036------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*I776MtbRoJmyX_FMYAHSIw.jpeg</url>
            <title>Stories by Bart Verkoeijen on Medium</title>
            <link>https://medium.com/@bgever?source=rss-3f5cfc632036------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 15:42:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bgever/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Making the Auth0 SPA SDK unit testable with Angular]]></title>
            <link>https://medium.com/@bgever/making-the-auth0-spa-sdk-unit-testable-with-angular-38eacd8af7e7?source=rss-3f5cfc632036------2</link>
            <guid isPermaLink="false">https://medium.com/p/38eacd8af7e7</guid>
            <category><![CDATA[auth0]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[single-page-applications]]></category>
            <dc:creator><![CDATA[Bart Verkoeijen]]></dc:creator>
            <pubDate>Thu, 31 Oct 2019 10:55:51 GMT</pubDate>
            <atom:updated>2019-10-31T10:55:51.646Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://auth0.com/">Auth0</a>, the authentication service and identity provider has a new <a href="https://auth0.com/docs/libraries/auth0-spa-js">SDK for Single Page Applications</a> (SPAs) that works well with Angular. Their dashboard has an Angular Quick Start, and in it they provide a tailored wrapper class for Angular to work with their SDK. When you extend this class you may run into the issue that you can’t easily mock the Auth0Client dependency. Read on to find out how to do this.</p><p>Part of the provided AuthService class looks like below.</p><pre>@Injectable({providedIn: &#39;root&#39;})<br>export class AuthService {</pre><pre>  // Create an observable of Auth0 instance of client<br>  auth0Client$ = (from(<br>    createAuth0Client({<br>      domain: &quot;example.auth0.com&quot;,<br>      client_id: &quot;ABC123abc123abc123ABC&quot;,<br>      redirect_uri: `${window.location.origin}`<br>    })<br>  ) as Observable&lt;Auth0Client&gt;).pipe(<br>    shareReplay(1), // Every sub receives the same shared value<br>    catchError(err =&gt; throwError(err))<br>  );</pre><p>The problem lies with the createAuth0Client function that is imported from the SDK. It provides access to the client object via a promise. Angular heavily depends on RXJS however, and to transform this into an observable, the from helper function is used. Other properties in the class are then chained to this observable to provide the authentication functionality.</p><p>For unit testing this is a dilemma, as it poses an external dependency that cannot be accessed. It is similar to directly using the browser’s document object versus an injected Document reference in your Angular code. Instead, when the class is created, this external dependency should be injectable via the constructor so that the object can be mocked and spied upon.</p><h3>Injecting the Auth0Client observable</h3><p>Since the Auth0Client is loaded asynchronously with a promise that is wrapped as an observable, it may seem impossible to create a dependency in the constructor to Observable&lt;Auth0Client&gt;. However, this is possible in Angular through the use of an InjectionToken.</p><p>As of Angular 6, the InjectionToken is now tree shakable and can leverage a factory function. That makes it easy to define our injectable token:</p><pre>export const AUTH0_CLIENT =<br>  new InjectionToken&lt;Observable&lt;Auth0Client&gt;&gt;(&#39;auth0Client$&#39;, {<br>    providedIn: &#39;root&#39;,<br>    factory: () =&gt; from(<br>      createAuth0Client({<br>        domain: environment.auth0.domain,<br>        client_id: environment.auth0.clientId,<br>        audience: environment.auth0.audience,<br>        redirect_uri: REDIRECT_URI<br>      })<br>    ).pipe(<br>      shareReplay(1), // Every sub receives the same shared value<br>      catchError(err =&gt; throwError(err))<br>    )<br>  });</pre><p>Next, this token can now be injected into the constructor of the AuthService class:</p><pre>constructor(<br>  // Use an injection token to get an observable instance<br>  // of the Auth0 client.<br>  @Inject(AUTH0_CLIENT)<br>  private auth0Client$: Observable&lt;Auth0Client&gt;,</pre><p>Because the token was marked with provideIn, and referenced in the injectable AuthService, it is discovered during build and included in the compilation. There is no need to expose it with a provider in a module.</p><h3>Mocking the Auth0Client in unit tests</h3><p>With the introduction of TypeScript’s Partial interface, it became a whole lot easier to mock type-safe partial implementations. With it we can mock for instance only one class function. We then can wrap that into an observable with the of helper function, and inject that into the AuthService.</p><pre>const clientStub = of&lt;Partial&lt;Auth0Client&gt;&gt;({<br>  getTokenSilently: async () =&gt; null<br>});</pre><pre>beforeEach(() =&gt; {<br>  service = new AuthService(<br>    &lt;Observable&lt;Auth0Client&gt;&gt;clientStub,<br>    // etc...<br>  );<br>});</pre><p>The above code mocks the result of the getTokenSilently function, to return a promise with an undefined token.</p><p>With this method it is also easy to spy on the mocks as well:</p><pre>const clientStub = &lt;Partial&lt;Auth0Client&gt;&gt;{<br>  getTokenSilently: async () =&gt; null<br>};<br>const clientStub$ = of(clientStub);</pre><pre>beforeEach(() =&gt; {<br>  spyOn(clientStub, &#39;getTokenSilently&#39;).and.callThrough();<br>  service = new AuthService(<br>    &lt;Observable&lt;Auth0Client&gt;&gt;clientStub$,<br>    // etc...<br>  );<br>});</pre><pre>it(&#39;should handle custom initialization&#39;, (done: DoneFn) =&gt; {<br>  service.init().subscribe(<br>    () =&gt; {<br>      expect(clientStub.getTokenSilently).toHaveBeenCalled();<br>      done();<br>    },<br>    error =&gt; fail(`Unexpected error: ${error}`)<br>  );<br>});</pre><p>Hopefully this gave you insight how to extend the AuthService class to make it possible to unit test it better.</p><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38eacd8af7e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a Full-Stack Web App Within Your Lunch Break]]></title>
            <link>https://medium.com/@bgever/deploy-a-full-stack-web-app-within-your-lunch-break-905cea827fc7?source=rss-3f5cfc632036------2</link>
            <guid isPermaLink="false">https://medium.com/p/905cea827fc7</guid>
            <category><![CDATA[to-do-list-app]]></category>
            <category><![CDATA[full-stack]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Bart Verkoeijen]]></dc:creator>
            <pubDate>Fri, 13 Sep 2019 09:36:02 GMT</pubDate>
            <atom:updated>2019-09-13T09:36:02.825Z</atom:updated>
            <content:encoded><![CDATA[<p>Splitting up your app into a frontend (web), backend (api) and database tier is a very common <a href="https://en.wikipedia.org/wiki/Multitier_architecture">multitier application architecture</a>. Though nobody really enjoys spending time setting this up, because hey, there’s another day gone… What if I told you this could be done within a lunch break, and you’d still have time left for eating your lunch? 🍔</p><p>I always dread the thought of these setups, because I need to hook up connection strings, URLs and lock things down properly on the backend. Then again, since these tiers are so common, there should be a standardized way to do it.</p><h3>Introducing KintoBlocks</h3><p>We realized that a lot of developers routinely have to go through the same steps whilst working on projects. Wouldn’t it be great if most of those steps could be automated? Oh, and hook up logging, a proper Continuous Integration (CI) process, and configure networking as an instantaneous bonus?</p><h3>The good old Todo List</h3><p>To make that point clear I wrote an example app, which is based on the excellent <a href="http://todomvc.com/">TodoMVC project</a>, that showcases various framework implementations with different languages. I extended the <a href="https://github.com/reduxjs/redux/tree/master/examples/todomvc">React + Redux implementation</a>, added the <a href="https://github.com/axios/axios">axios library</a> to sync data to the <a href="https://hapi.dev/">hapi</a> Node.js backend API, and that API stores the todos into a MongoDB.</p><ol><li><em>Frontend:</em> React + Redux TodoMVC SPA (<a href="https://github.com/kintohub/todolist-spa-example">source</a>)</li><li><em>Backend:</em> Node.js hapi REST API (<a href="https://github.com/kintohub/todolist-api-example">source</a>)</li><li><em>Database:</em> MongoDB cluster; replica set of 3 (<a href="https://hub.helm.sh/charts/stable/mongodb-replicaset">source</a>)</li></ol><p>Can you start to feel the cringe already? Replica sets… A backend that needs to be exposed to the public internet but also needs to talk to the internal MongoDB custer?</p><h3>Easier than you think</h3><p>Back to the KintoBlocks; in KintoHub there are three flavors of KintoBlocks that are perfectly suitable for the web, API and database tiers.</p><p>First, there’s the <strong>Website</strong> block. It automatically creates an HTTPS endpoint for you. When you pick a <em>Dynamic Web App</em> type, then you just need to point to the internal port that your Node.js server (HTTP) runs on. Talking about Node.js, it is one of the many programming languages that are supported out of the box. Under the hood, it’s wrapping the code into a Docker container that has all the SDK stuff installed already, but you don’t need to worry about that. Simply call NPM to install the dependencies as the build command, and specify in another command how to start the app.</p><p>Second, the <strong>Microservice</strong> block is meant for internal business logic. Perfect for the backend API. However, the microservice should also serve a public endpoint for the frontend to call. No problem, you can expose a microservice through KintoHub’s auth-protected gateway, or if it is public data like in this case, simply enable public access without authentication.</p><p>Last, the <strong>Custom Service</strong> block that supports <a href="https://helm.sh/">Helm charts</a>, makes it almost too easy to deploy pre-composed cloud-native services like a MongoDB cluster. The community has built templates (charts), for which you only need to set a few arguments, to configure a complex application. You can find out more <a href="https://hub.helm.sh/charts/stable/mongodb-replicaset">in the details of such chart</a>.</p><h3>See for yourself</h3><p>All the above steps have been neatly laid out in a <a href="https://docs.kintohub.com/docs/examples/todo-list/tutorial"><strong>Todo List quick-start tutorial in our KintoHub docs</strong></a>. I encourage you to try it out yourself, by <a href="https://try.kintohub.com/beta/?utm_medium=display&amp;utm_source=Medium&amp;utm_campaign=blog&amp;utm_content=todoListTutorial">signing up for KintoHub</a>. Also, if you’d like me to demo this to you in a short time — say your lunch break 😉 — feel free to <a href="https://cal.mixmax.com/kintohub/onboarding?utm_medium=display&amp;utm_source=Medium&amp;utm_campaign=blog&amp;utm_content=todoListTutorial">book a 30min demo with us</a>. I’m happy to show you around, and thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=905cea827fc7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OSCON Recap — Questions Asked]]></title>
            <link>https://medium.com/@bgever/oscon-recap-questions-asked-16e76b9fd648?source=rss-3f5cfc632036------2</link>
            <guid isPermaLink="false">https://medium.com/p/16e76b9fd648</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[product]]></category>
            <category><![CDATA[oscon]]></category>
            <category><![CDATA[graphql]]></category>
            <dc:creator><![CDATA[Bart Verkoeijen]]></dc:creator>
            <pubDate>Thu, 12 Sep 2019 08:17:01 GMT</pubDate>
            <atom:updated>2019-09-12T08:17:01.642Z</atom:updated>
            <content:encoded><![CDATA[<h3>OSCON Recap — Questions Asked</h3><p>KintoHub had a booth at OSCON, <strong>O’Reilly’s Open Source Convention</strong>, last 17–18 July. Trevor Rosenbery and Bart Verkoeijen were there to answer questions. This is a digest of discussions that came up and those questions answered.</p><h3>Hasura is awesome!</h3><p>We had quite a few visitors to our booth after our <a href="https://conferences.oreilly.com/oscon/oscon-or/public/schedule/detail/76285">talk on Hasura</a>. We’re big fans of the <a href="https://hasura.io/"><strong>GraphQL API for PostgreSQL</strong></a>, and use Hasura in the KintoHub dashboard to trigger UI updates.</p><p>What is impressive about Hasura is that <em>it is surprisingly easy to setup async communication between your frontend and backend services.</em> It doesn’t require any knowledge on Websockets, and beautifully abstracts async system patterns with GraphQL.</p><p>PostgreSQL serves as the backing store for messages. It does not mean you’ll need to switch over your business logic to use postgres tables. Instead, you’d communicate through Hasura with <a href="https://graphql.org/"><strong>GraphQL</strong></a><strong> queries and mutations</strong>. Why PostgreSQL then? It has recently added subscriptions, and Hasura resurfaces those subscriptions as <strong>GraphQL subscriptions</strong> over Websocket. Plus, both are open-source, and the two combined are easy to operate. Simply spin up Hasura containers as needed, and connect them to your PostgreSQL database with a simple connection string.</p><p>We demonstrated that this can be done very quickly on KintoHub. Have a look at the <a href="https://www.youtube.com/watch?v=UTmCPEtxALk">talk recording on YouTube</a> to see KintoHub in action.</p><h3>Building cloud-native apps</h3><p>Many booth visitors told us that they have worked with <strong>Kubernetes </strong>already, and are excited about its capabilities, but also feel overwhelmed with its complexity. In fact, some mentioned it’s so overwhelming that they haven’t even attempted to learn it, and question whether Kubernetes is necessary for your projects.</p><p>We agree, whilst Kubernetes is useful and certainly has its place, <em>the complexity makes adoption hard.</em> That is why we <strong>abstract away the details of Kubernetes</strong> in the KintoHub dashboard. At the same, we do run KintoHub as a layer on top of Kubernetes.</p><p>This way you can still leverage the orchestration powers of Kubernetes;</p><ol><li>easily add new services to your projects,</li><li>operate and scale your services,</li><li>spin up multiple environments, and</li><li>enable service-to-service communication.</li></ol><p>Plus, should you find out later on in your project that you need the full power of Kubernetes, then you are already ready to go.</p><p>Mentioning editing Kubernetes <strong>YAML files</strong> made some booth visitors visibly shudder, and that resonates with us. <em>Struggling with syntax and herding files takes the fun out of shipping code or ideas.</em> At KintoHub we are committed to solve this problem with a simple abstraction we call <strong>KintoBlocks</strong>. Rather than thinking in combinations of definition files, you can think of your services as visual blocks that you stack together to make a project deployment. Simple but effective.</p><h3>Docker &amp; Helm charts</h3><p>Most of the booth visitors were already familiar with Docker, and the concept of <strong>containerizing your applications</strong>. It is great to see how Docker has democratized a container format that allows us all to ship apps easily into the cloud.</p><p>The same cannot be said about <strong>Helm charts</strong>, yet. This concept was still new to many booth visitors. However, we believe it has great potential to simplify your cloud-native deployments. For example, popular services like Redis, PostgreSQL, MongoDB and the like can easily be deployed with this template system for <strong>cloud-native service packages</strong>.</p><p>Rather than interacting with a CLI, deploying such Helm charts with KintoHub is as easy as cloning a Helm chart repository and passing any required arguments for the build step on our dashboard. Check out our <a href="https://docs.kintohub.com/docs/examples/todo-list/tutorial">Todo List example app tutorial</a> that explains how to deploy a MongoDB replica set with 3 instances using a helm chart.</p><h3>Aligning teams</h3><p>Another frustration that was brought up repeatedly, is that in larger teams and organizations, <strong>not everyone is on the same page</strong> with building cloud-native apps.</p><p>Lots of team leads mentioned that their teams are <strong>burning cycles on training and getting up to speed</strong> using the tools. Then again, you don’t want to give up on control, your DevOps people are critical in ensuring that the nitty-gritty things like network security are in order. How can KintoHub help there?</p><p>We recognize that challenge, and that is why we have functionality like:</p><ul><li><strong>Workspaces</strong> per team, isolating projects and services.</li><li><strong>Projects</strong> that have their own set of environments.</li><li><strong>Enterprise hosting option</strong> with full access to your Kubernetes clusters.</li><li><strong>Customization</strong> of deployment scripts for specific needs.</li></ul><p>It provides developers with a uniform approach to access projects and deployments, whilst the DevOps team still has control of the underlying Kubernetes cluster. This way, devs can focus on their code, and DevOps on operating the infrastructure and ensuring all controls are in place.</p><h3>Using KintoHub</h3><p>We’ve received <strong>many compliments on our UI</strong>. We were happy to hear that, and we also take pride in how we’ve been able to simplify the app delivery process.</p><p>KintoHub does that by splitting the UI up into 2 parts:</p><ol><li><strong>Building KintoBlocks</strong> — logical units of services like websites, microservices and custom services (databases, queues, caches).</li><li><strong>Deploying to environments</strong> — composing your projects with KintoBlocks and a simple one-click deployment process, even for copying entire environments over.</li></ol><p>To make that point clear, we ran a challenge for newcomers to time how long it took from signing up, to composing a deployment with a KintoBlock, and finally hitting the <em>Deploy</em> button. The fastest time was a mere 13 seconds!</p><p>Feel free to <a href="https://cal.mixmax.com/kintohub/onboarding?utm_medium=display&amp;utm_source=Medium&amp;utm_campaign=blog&amp;utm_content=osconRecap">schedule a demo with us</a> if you’d like to see that in action.</p><h3>Practical questions</h3><h4>How do I call my services?</h4><p>Setting up <strong>HTTPS</strong> endpoints, <strong>exposing microservices</strong> to be called from the outside, and <strong>ingress</strong> configuration, were all things you told us you dread to configure.</p><p>This functionality is built into our concept of KintoBlocks. For instance, the <strong>Website</strong> KintoBlock includes automatic configuration of an HTTPS endpoint. You just need to point to the correct internal HTTP port that your server is listening on.</p><p>The same for <strong>Microservices</strong>, these can be accessed using KintoHub’s OAuth-based <strong>authentication and API gateway</strong>. This makes it easy to connect outside projects or APIs to the services running inside the cluster.</p><h4>Does it limit our DevOps team?</h4><p>Some concerns were raised that DevOps team members may not like us. We would argue that this is rather the opposite. <strong>KintoHub makes DevOps’ lives easier</strong> in that they can give developers access to their managed Kubernetes clusters through KintoHub, without worrying that the developers mess up the cluster configuration. Since KintoHub orchestrates the workflow for the developers, this process becomes more uniform. Moreover, the Enterprise plan allows to customize our configuration scripts. And finally, we never block you from accessing your cluster, you keep full control.</p><h4>How to host KintoHub?</h4><p>Some booth visitors preferred that <strong>KintoHub hosts their apps</strong>, and for others they preferred to <strong>host KintoHub on their own cloud subscriptions</strong>. We support both. Our SaaS plan gets you started quickly and is ideal for quick experimentation and will be sufficient for many projects. If you need that extra fine-grained control or want to leverage your existing cloud subscriptions, we also support that with our Enterprise plan. It’s even possible to run KintoHub on your on-premise cluster.</p><p>Want to try it for yourself, <a href="https://try.kintohub.com/beta/?utm_medium=display&amp;utm_source=Medium&amp;utm_campaign=blog&amp;utm_content=osconRecap">sign up for access to our beta!</a></p><h3>One question we missed</h3><p>One thing that surprised us is that not many booth visitors asked how to <strong>debug apps or see logs</strong>. This appears to be an after-thought that only comes up when problems arise.</p><p>Getting <strong>log collection and the ability to search those logs</strong> out of the box, is something that is really nice when you are in the midst of solving an issue. You don’t want to waste cycles to setup these basic capabilities every time a new project is started. Maybe all booth visitors expected to have that from the get-go, and the good news is that this is the case. 😊</p><p>—</p><p>That wraps up this recap of our OSCON visit. Thank you for reading, and if you stopped by, it was great to speak, and otherwise we hope to see you next time! 👋</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16e76b9fd648" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[With new Serverless options available, it’s time to get on the bandwagon!]]></title>
            <link>https://medium.com/@bgever/with-new-serverless-options-available-its-time-to-get-on-the-bandwagon-a84f166c77c?source=rss-3f5cfc632036------2</link>
            <guid isPermaLink="false">https://medium.com/p/a84f166c77c</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Bart Verkoeijen]]></dc:creator>
            <pubDate>Fri, 05 Jul 2019 09:27:14 GMT</pubDate>
            <atom:updated>2019-07-05T09:27:14.508Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS Lambda has popularized that Serverless and Functions as a Service (FaaS) mean the same. With the rise of new serverless technologies like databases and containers, the term ‘serverless’ has broadened. Let’s boil it down to its true meaning, as it seems that no one can agree on a standard definition. Here’s how we at KintoHub think about serverless, and how you can leverage this hot tech.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZoUYwLI9IN5v7ls_" /><figcaption>Photo by <a href="https://unsplash.com/@tvick?utm_source=medium&amp;utm_medium=referral">Taylor Vick</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Paying for compute resources</h3><p>For decades we have been defining compute resources in a number of servers, as that was how you would procure the hardware. Cloud vendors have changed that by turning capital expenses (CapEx) into operational expenses (OpEx), through dynamically provisioning resources and charging for them by the hour or even second. Virtual machines (VMs) made that even more flexible by increasing the density of virtual servers you can run on physical hardware.</p><blockquote><strong>Yet you always have to pay 24/7, as you need to provision the resources, whether they are in use or not.</strong></blockquote><p>And that is what makes <em>serverless</em> different. You are no longer paying for the <strong>number of servers</strong> that you require, but based on the <strong>cost of operation </strong>down to the millisecond.<strong> </strong>If nothing is in operation, and the underlying servers are idle, then you do not pay anything.</p><p>Note; I did not say <em>cost of execution. </em>That would imply that the charging mechanism is always based per executed request, like it is with FaaS. The method of charging for serverless can be different depending on the type of technology, as we will see that later when we look into examples.</p><p>How you are charged for resources is much more fine-grained with serverless. Especially once your applications get variable traffic spikes, and that brings us to scaling.</p><h3>Simplifying scalability</h3><p>The cloud is known for offering the capability to scale up (better hardware) and scale out (more hardware). But <strong>scaling on demand</strong> is not as easy as it sounds. Most cloud experts will admit that configuring which factors determine how an application should scale requires time, knowledge, and experience.</p><blockquote><strong>Serverless has been <em>designed for scale</em> from the get-go.</strong></blockquote><p>A serverless platform has <strong>units to measure <em>demand,</em></strong> and handles managing the underlying resources to process that demand for you.</p><p>The good news is that you don’t need to worry about these details with serverless. You can simply build your application based on these units, and the system will scale accordingly. The serverless platform handles the tricky bit of responding to changing demand.</p><p>That is why it is called a <strong>serverless <em>platform</em>,</strong> since something will need to respond and handle the processing. Moreover, the platform deals with the servers; configuration, provisioning, storage, networking, monitoring, etc. This allows you to <strong>focus on the code only,</strong> finally!<strong> 😌</strong></p><p>Because the platform handles the demand response, it is capable to do that with great flexibility. The platform can pause or even hibernate the application when there is no demand. Or allocate automatically scale up and down server capacity unpredictable or burst demand. You no longer need to over-provision capacity.</p><p>With Functions as a Service, its unit of demand is obviously the invocation of a function. However, new serverless frameworks are emerging that use different types of units, let’s compare them.</p><h3>Types of serverless</h3><p>Before we dig into the various types, there is one concept that all of them have in common; state. Or rather, the lack of it; <strong>stateless computing.</strong></p><p>Most of us have been taught to program with state; in-memory stores, session data, databases, n-tier, etc. However, <strong>state is the arch-enemy of scale,</strong> as it blocks the ability to distribute processing without the need to tie it all somehow together. Serverless forces us to relearn how to architect solutions that scale by leveraging stateless design patterns. Note; some platforms do support state, but suffer performance penalties when used with state. Keep that in mind.</p><h3>Functions as a Service (FaaS)</h3><p>It is the most familiar type, popularized by <a href="https://aws.amazon.com/lambda/">AWS Lambda</a>, and replicated by others like <a href="https://azure.microsoft.com/services/functions/">Azure Functions</a> and <a href="https://cloud.google.com/functions/">Google Cloud Functions.</a> This type uses the <strong>invocation of a function</strong> as a unit. The frameworks for FaaS support specific programming languages, and avoid the hassle of managing language runtimes. You simply provide your code in the form of a function or method, and it gets executed within a context.</p><p>The context is restricted, and designed around the concept that the <strong>execution should be short-lived.</strong> This makes the execution of the unit <em>predictable,</em> and that allows the underlying resources to scale when many functions need to be executed.</p><h3>Serverless Containers</h3><p>Container orchestrators like <a href="https://kubernetes.io/">Kubernetes</a> have made it easy to manage a compute cluster to spin up containers and control the amount of replicas.</p><p><a href="https://virtual-kubelet.io/">Virtual kubelet</a> made it possible to rapidly expand beyond the default cluster capacity, and leverage serverless scaling for containers.</p><p>Frameworks like <a href="https://knative.dev/">Knative</a> and <a href="https://github.com/kedacore/keda">KEDA</a> handle <strong>the process of scheduling new containers and stopping them depending on the demand.</strong> You can set what triggers the scaling, say the length of a queue, or incoming events. Now your application can easily leverage an <em>event-driven architecture </em>to scale on demand.</p><h3>Serverless Databases</h3><p><a href="https://aws.amazon.com/rds/aurora/serverless/">AWS Aurora Serverless</a> and <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-serverless">Azure SQL Database Serverless</a> are examples where cloud providers have added serverless capabilities to their database engines.</p><p>The unit of demand for this type is the <strong>additional capacity charged per second.</strong> Moreover, you can <strong>completely shut down</strong> the database if your application scenario can accept a <em>warm-up delay </em>before the database resumes.</p><p>This is great for workloads that require the database to be available intermittently, or when the workload has variable capacity spikes.</p><h3>Considerations before you go serverless</h3><p>Now FaaS has been around for a while, there are some learnings that apply to these other types of serverless as well.</p><p>I’ve already mentioned that you should keep things stateless. Another consideration is that every serverless platform has <strong>some form of delay to execution, or <em>cold start.</em></strong> The way these platforms save you money, is by not running anything when there is no demand. That also means that when demand rises, you need to instantiate more resources. We all know that <strong>this isn’t instantaneous,</strong> there is some <em>initialization time</em> to be aware of. If you need super low latency startup times, then you might be better off to over-provision with resources that are ready to go.</p><p>Another possible challenge is <strong>debugging.</strong> Whilst the serverless platforms abstract the underlying runtime, it also means you are at the mercy of how much control the platform gives you. This may change the development workflow that you’re used to.</p><p>That highlights the importance of <strong>logging,</strong> as this would be your primary way to show application output for debugging. Related to this is knowing what<em> metrics</em> the platform exposes for <strong>monitoring your solution.</strong> You want to be aware when a traffic spike happens, as this would directly affect the cost of running your application.</p><p>To summarize, consider the following:</p><ul><li>Stateless</li><li>Startup time</li><li>Ability to debug your code</li><li>Logging</li><li>Monitoring</li></ul><h3>MOAR! serverless 😁</h3><p>It is great to see that there are more severless solutions available. It allows us developers to focus on our code, and remove the overhead of managing the infrastructure of the application. Serverless applies not only to functions, and now extends to general computing like containers and databases. This allows us to leverage the benefits of serverless across our applications. Go write some code!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a84f166c77c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Case for Microservices]]></title>
            <link>https://medium.com/@bgever/the-case-for-microservices-abaf961b848d?source=rss-3f5cfc632036------2</link>
            <guid isPermaLink="false">https://medium.com/p/abaf961b848d</guid>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Bart Verkoeijen]]></dc:creator>
            <pubDate>Sat, 06 Apr 2019 08:53:27 GMT</pubDate>
            <atom:updated>2019-04-06T09:06:23.467Z</atom:updated>
            <content:encoded><![CDATA[<p>In my 17 years of programming, I overcame many hurdles of software development. The most significant one was how to deal with <strong><em>spaghetti code.</em></strong><em> </em>It has set the foundations for how I handle complex challenges, still to this day. It applies to microservices as well. Let me explain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qz5JNLA4D_cSOCjj" /><figcaption>Photo by <a href="https://unsplash.com/@keriliwi?utm_source=medium&amp;utm_medium=referral">Keri liwi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As the applications I wrote grew bigger and bigger, so did their complexity and dependencies.</p><p>I struggled.<br><strong>It became a serious maintenance burden.<br></strong>Something had to change.</p><p>Those were the days of PHP4, when ‘app development’ was called ‘scripting’. Where web pages contained logic that was only applicable for that specific page. But my pages were growing.</p><p>I needed content management. So there were dependencies between pages. And if I would change logic one page, it could — and often would — affect other pages.</p><h4>Dependency Injection to the rescue!</h4><p>That’s when I discovered <em>Dependency Injection.</em> By using <strong><em>interfaces</em></strong> I was able to abstract how my code was tied together. I could change the underlying implementation, but the contract, the interface, that would still work the same.</p><p>This is what allowed my applications to grow, to sizes what we nowadays call <strong><em>monoliths.</em></strong><em> </em>I used DI frameworks, structured my monoliths into multiple libraries, to keep the overview. Life was good.</p><h4>Growing teams</h4><p>Until the teams I worked on started to grow.</p><p>There are growing pains when your codebase changes from a solo contributor to a collaborative team. Thoughts of “Others working in ‘my’ codebase.” Or having to work on others’ codebases, where sometimes those maintainers no longer work at the company. And then there’s your past self. I’ve been there, to look up in git with git blame who wrote that CrappyCode™, only to find it was myself, years ago. 😅</p><p>I realized that when teams start to scale, it becomes important that the codebase can scale along. And with more people, more opinions are raised. This needs to be factored in.</p><h4>Autonomy</h4><p>And that’s what <strong><em>microservices</em></strong> bring to the table. The ability to break down the monolith into smaller pieces that are therefore easier to maintain. Moreover, those microservices can be maintained with their own autonomy over what implementation to use. Use the best tool for the job, and all that.</p><p>This doesn’t mean that those maintainers work in isolation. <strong>Far from it.</strong></p><h4>Interfaces and APIs</h4><p>This takes us back to the spaghetti code. Where the interface was the glue, and where the implementation could be whatever it needs to be.</p><p>And that is the same for microservices. The teams working on individual microservices still need to work together to <strong>design a meaningful web of APIs.</strong> Essentially, the <strong>interfaces of the microservices.</strong></p><p>We are no stranger to this as web developers. We’ve been tying up web APIs for years. And the use of standard protocols like REST and JSON, have made that only easier.</p><p>Think of using external web APIs to send email or push notifications, receive structured data, embed web content, etc.</p><p>In fact, let me explain this with a real world example.</p><h3>An example: tech events</h3><p>I’ve been considering to build a website for the tech community in Hong Kong. There are many separate tech events happening. I’ve noticed that fellow devs missed out on events they would like to go to, because they simply were not aware of them. Thus the idea of a <strong>website with a consolidated list of events</strong> was born.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*X2y5wrqgjUp2il7m" /><figcaption>Photo by <a href="https://unsplash.com/@jankolar?utm_source=medium&amp;utm_medium=referral">Jan Antonin Kolar</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Normally I would build a ASP.NET monolith, with a frontend and admin panel to curate and store events in a database. There was an implementation detail though, that I would need to scrape and scan for events posted on known places. Think: Meetup, Facebook, Eventbrite, and their own websites.</p><p>This means I would go beyond the typical standard fit of the request/response pipeline of my ASP.NET website. For a monolith I would usually introduce a new architectual layer to handle this. But with microservices, everything is already broken up in layers, so it’s a lot easier.</p><h4>The services</h4><p>I would consider to break up the application into the following services.</p><ol><li><strong>Web Frontend </strong>— where a curated list of events is displayed.</li><li><strong>Web Admin</strong> — where admins can review events that have been scraped and approve or modify them.</li><li><strong>Auth</strong> — to handle logins for the <em>Web Admin.</em></li><li><strong>Database </strong>— where events are stored.</li><li><strong>Events </strong>— retrieval and storage of events in the <em>Database,</em> to be used by the <em>Web Frontend, Web Admin</em> and <em>Scrapers</em>.</li><li><strong>Scrapers</strong> — various scrapers that run at regular intervals to check whether new events have been announced, or events have been updated. Scraped events are stored using the <em>Events</em> service.</li><li><strong>Notifier</strong> — sends emails to the admins when new events have been detected, so they can be reviewed on the <em>Web Admin.</em> Triggered via push message from the <em>Events</em> service.</li></ol><p>As you can see, by breaking up the services, I have much more autonomy in maintaining these individual services. Moreover, say a scraper requires the use of a specific client library written in Go, to access the content. I could easily write that specific scraper entirely in Go, while I still can keep the rest of my system written in C#.</p><p>Over time, someone else could take up the maintenance of a specific service. They would need to work together with the team to make sure the APIs align. But at the same time, they have the autonomy to introduce new functionality for the service they maintain.</p><p>This is what makes microservices so exciting. I hope this gives some insights to why you could consider to leverage microservices to do the same.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abaf961b848d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>