Decoding the code

Mariusz Krzanowski blog

Long polling as a cure for message push mechanism

Introduction

Many times in your life, you will have the situation when your server must push information to your customer. When you are not limited to HTTP/HTTPS you can setup TCP/IP connection and problems are solved. Unfortunately we are living in a world dominated by HTTP protocols. When you ask someone how to address such a challenge you can hear from your colleagues that Webhook (https://en.wikipedia.org/wiki/Webhook) is a solution for your problem. My goal is to convince you to try to think outside the box and focus on long pooling mechanisms.

TCP limits that can break your Kubernetes cluster

Introduction

Microservices solutions are more and more popular. Docker, Kubernetes are more and more popular, even the hardest opponents start to give up. Unfortunately we – Software Developers – usually do not like to focus on network protocols. That ignorance can sometimes be a blessing, but sometimes can hit us hard in the most painful time. In this article I want to focus on the Transmission Control Protocol protocol limits of source and destination ports size and why it can be painful for us.

When retry never succeeds

Introduction

Software development is a craftsmanship in which we are trying to satisfy clients’ needs. Resiliency is one of those needs. We are aware that sometimes database connection can fail or we can have other transient errors like being chosen as a deadlock victim. In case of transient errors a good practice is to retry a failed process, to try to succeed in the next try. In .NET world many developers use  e.g. Polly https://github.com/App-vNext/Polly to add a retry policy for chosen methods.

Problem with IoC and Scoped Lifecycle

A bug we found a few months ago in the legacy code has proven that developers usually are focused on success scenarios and do not spend a lot of time on failure analysis in advance.

Azure Functions V3 and disappearing function.json files

Introduction

When I started migration process to Azure Function 3.0 of an existing project, I have discovered small, but painful inconvenience. The problem was that all function.json files were permanently removed from output folder just before Azure Function Tools func.exe was started. I have to confess it was very annoying. There were suggestions e.g. on StackOverflow or other sites to run PowerShell which copies files later – after emulator is started, but it was not a solution I like.

Is Liskov Substitiuton Principle violated by async pattern?

The async/await keywords change methods behavior. When async/await pattern is used, the method never throws an exception. The method always returns a task which can be eventually Faulted, Canceled or RunToCompletion. So why do I think about violating Liskov Substitution Principle?

Exception filters to catch first thrown exception

Introduction

This post is inspired by the book ‘C# in depth’ by Jon Skeet and presentation ‘Internals of Exceptions’ made by Adam Furmanek. The topic I want to focus on is stack unwinding when an exception is caught.

The time complexity trap in dictionaries

We developers often think about time complexity. We are familiar with the fact that time complexity is the main factor, which helps us create really powerful algorithms. When we need to store data requiring random access, we use hash sets or dictionaries. Why do we do this? Because we know, that time complexity is O(1) for that kind of stores.

When we use Dictionary<TKey,TValue> we think that access via key is really fast. We expect O(1) time complexity. We are right when we think about algorithms usually implemented inside dictionaries. The truth is that we are right only when we consider dictionary implementation only. What we are missing sometimes is the time complexity of two operations that must be calculated while accessing the value by the key. Those operations are:

ConcurrentDictionary and race condition

Introduction

The goal of this article is to show the problem of race condition while execution of GetOrAdd(TKey, Func<TKey, TValue>) method. The described problem has a few solutions. I will focus on one I found at StackOverflow, and I will explain why this solution works.

Double execution problem

Not everyone realizes that  GetOrAdd(TKey, Func<TKey, TValue>) can call multiple times the delegate resolving value for a single key. It is easy to prove this thesis with the following code.

Intensive cache miss

Introduction

It is common knowledge that using cache can speed a lot our applications. In this post I would like to focus on application design using cache. The simplest scenario using cache that I frequently see follows this algorithm.

Idempotence in sending e-mail

When you build a distributed system it is difficult to design good transaction guarantee mechanism. If your communication is asynchronous, you communicate with remote services using some messaging system. I guess you already know that network is not reliable, so your message can be lost. To guarantee message delivery you have to resend it when confirmation is missing. There are solutions to guarantee idempotence for the service receiving data. What I want to share is my idea how to make sending e-mail service as close as possible to the idempotence solution.

Page 1 of 3

Powered by WordPress & Theme by Anders Norén