Posts

Showing posts with the label aws

Why I Hate Microservices Part 2: The Who's Telling the Truth Problem 🤷

Image
      When designing a system, you should not limit yourself with using only one type of databases. Some business needs might require having a more flexible sort of databases like NoSQL / Document databases.  One of these databases is Elasticsearch ,   which is a topic that I have talked about in a previous post that you should definitely check out. However, if you use more than one database for your system, making sure that all your databases are in sync is crucial . How It Started 🚩 As I said in my previous post . The other sort of problems that we have faced while working on the microservices project is data inconsistency. To explain this problem I have to tell you why the system needed an Elasticsearch index. In microservices projects you usually have more than one database, one for each service/domain. The client-side needed an aggregated document of the data from all the databases. Which in microservices is called The Aggregate Root ,   and that is ...

Why I Hate Microservices Part 1: The Russian Dolls Problem 🪆🪆🪆

Image
     People always want the newest things. The more trendy something is, the more it appeals to most people. Same applies to technology. Adding the word microservices to the CV can help it shine a little bit. These are some of the thoughts I was having while I was 2 hours deep into debugging an issue in a project that involved .Net, Kafka, SignalR, React js, Elasticsearch, ECS, MediatR and more. Beware of Microservices  ⚠️ What I'm about to share is a cautionary tale for people who are on the verge of shifting their solution into a microservices architecture. Before you start implementing such an architecture, please read carefully the decisions that others have made along with their consequences so that you can see for yourself the outcome of each design decision instead of falling for the same mistakes. Before anything : The case study that I’m about to discuss might have had its problems. However, the people who made the design decisions are very good software e...

Download File from S3 Bucket API Using AWS .Net SDK

Image
  In one of my previous posts  Upload File to S3 Bucket API Using AWS .Net SDK  I explain how to upload a file to an S3 bucket and get the file path where your file was stored. Assuming that you have persisted this file path somewhere somehow, I will show you in this post how to download the file using the file path. Using the same set-up in my previous post linked above let's start with adding an interface method that performs the needed service. File Data When the S3 SDK gets you the object that exists in the file path and bucket name provided, it's in the form of a stream. You should have a content type so that you are able to tell the receiver of your API what type of file they are getting. Luckily, we can get this information from the Content-Type header from the response, but we need a model that can hold this piece of information. So, let's create a class named FileData which can hold the stream and the content type of the file received from S3. namespace Domain....

Upload File to S3 Bucket API Using AWS .Net SDK

Image
AWS has become an integral part of many software projects as it offers a wide variety of services that could help any project achieve their goals. The S3 bucket is one of those services. Using the SDK that AWS provides, managing files on your S3 bucket has never been easier and I will show you an example of how to upload a file to an S3 bucket. Let's create this API using traditional clean architecture and not using CQRS or MediatR like my previous post. Just because Command and Query offer a looser coupling but in smaller scale projects with not that much business logic and entity operations it wouldn't make sense to keep creating 2+ classes every time you would want to add a new entity action. So, let's start up with an interface for our AWS services class. Interface First, we add an interface so that the controller can use to call the upload service after providing it with a bucket name, path inside the bucket and of course the file itself but as a MemoryStream . namespa...