Elastic Beanstalk is a great platform, it offers both a
Web tier and a
Worker tier. I recently wrote about Simple Routing one of my library that allows you to route a
SQS message to a specific endpoint on the
Beanstalk works great once it’s deployed to
AWS there is no easy way to run it locally. As soon as you want to execute an end-to-end flow involving both the
Web and the
Worker you need to manually
POST requests to the
Worker using Postman which is cumbersome and error-prone.
Singleton HTTP Client
Even though the
IDisposable it is supposed to be used as a singleton as stated in the API reference:
HttpClientis intended to be instantiated once and re-used throughout the life of an application. Instantiating an
HttpClientclass for every request will exhaust the number of sockets available under heavy loads. This will result in
The accepted best practice is to have one
HttpClient per HTTP endpoint you’re interacting with. This will not only yield better performance it also allows to encapsulate endpoint specific logic (such as setting headers).
Now the question is: how do you configure your
IoC container to resolve the expected
HttpClient instance? This used to require a cumbersome registration but
.NET Core 2.1 will ship with the HttpClientFactory making our life much easier.
Simple Routing for Elastic Beanstalk Worker tier
Elastic Beanstalk offers both a
Web tier and a
Worker tier. This allows developers to build reasonably complex applications without having to maintain moving pieces. Offloading heavy-duty workloads to the worker in order to keep the web tier responsive is as easy as putting a message on a queue.
One annoyance that I have with
Beanstalk is that there is no way to direct a message to a specific endpoint, hence leaving a single endpoint the responsibility of distributing the messages to all their handlers and potentially leading to brittle code. But it doesn’t have to be that way.
Links Insights #1
Every now and then I stumble upon a brilliant post on Internet, I share some of those links on my Diigo profile but the format is very succinct. I decided to start a new experiment and instead write full blog posts about those links. The first reason is quite selfish as I would like to keep a record of what I thought was interesting and why, I also hope to empower the reader so that she can decide if she wants to read the full post as some of them are lengthy.
I’m considering limiting each of those post to up to three links as to not require too much time from the reader.
This is inspired by the excellent work that Chris Alcock and Michael Wolfenden are doing with respectively The Morning Brew and The Wolf Report. Don’t be surprised if I end up
stealing borrowing some links from them.
Without further ado let me get started with the first links.Continue reading