Mariusz Krzanowski blog

Tag: Distributed Systems

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.

Review of Designing Data-Intensive Applications by Martin Kleppmann

Today I finished reading a book ‘Designing Data-Intensive Applications’ written by Martin Kleppmann. I would like to share with you my review of this book.

In my view designing and development of any distributed system is a hard work. My opinion is based on over a decade of experience in this subject. The problem is that all modern applications are distributed in some way. If a database is hosted on a different computer than a web server, there is a communication link. You have two services – database service and application service – which share an unreliable network as a communication channel. The browser hosting client code which connects to the web server creates distributed system as well. 

Developing workflow without workflow engine

Disclaimer

Workflow engines are very advanced tools and I saw a lot of projects where they created great business values. They sometimes simplify development. In this article I do not argue that you should not use them. My goal is to show you that there is an alternative – transformation from workflow into set of services distributed in the future.

World without DTC

Distributed Transaction Coordination is sometimes slow, but guarantees the system consistency. You do not need to care about infrastructure things. I will describe a problem that appears when you have no DTC and you have two independent databases.

Powered by WordPress & Theme by Anders Norén