A step-by-step guide to goroutines & channels

Image for post
Image for post

Go is widely being used for backend programming and its community is growing larger each day. Most people choose Go because of its easy-to-implement concurrency abilities.

This story is about how to implement concurrency in Go with a step-by-step guide. So this story considers you already know the basics of concurrency from other programming languages.

Lightweight: Creating a goroutine requires only 2 KB of heap space. They grow by allocating and freeing up space as needed. For comparison, Threads get created with 1 MB. A server that processes incoming requests can easily create a goroutine per request.

Doesn’t use OS threads: Goroutines are created and destroyed during runtime, therefore no need to request resources from the OS. …

The story of migrating a 1 million throughput domain

Image for post
Image for post
“Technology is the driver, ecommerce is the outcome.”

Favorites in Trendyol, most people in Turkey have either used it or heard it.

We’ve stopped using GraphDB and transformed our datasource to NoSQL (Couchbase) without losing essential features. We wanted to share our experiences and tell you why and how we did it.

Let’s first start with our legacy design:

Lately, in our team in Trendyol, we’ve slowly adapted Quarkus for our Java projects, due to its high performance (and we definitely recommend it!).

In this particular API, we wanted to send messages to a topic and we were pretty used to doing it in Spring, but it was our first try in Quarkus.

We’ve spent lots of time getting the hang of it. So I wanted to share how you can implement it and save you the trouble.

Image for post
Image for post

Eclipse Microprofile Reactive Messaging (the Reactive Messaging Client which Quarkus’ official documentation uses) didn’t support what we wanted to accomplish.

It provides an @Outgoing annotation which can be triggered by an incoming message to the API. In our case, there were not going to be an incoming message, we wanted our API to just produce a message. Simple as that. …

aka Bogosort

I was spending a lot of time lately thinking about how I can improve my program’s sorting performance a little bit more. I was thinking:

Hey, there are sorting algorithms that have proven themselves well and that everyone knows, but there must be something we all are missing, maybe?

Well, I found something and I wasn’t wrong. There was something that we didn’t know much about, though it wasn’t exactly what I was looking for.

I found a really slow sorting algorithm called Monkey Sort aka Bogosort.

Image for post
Image for post
Photo by Brian Mann on Unsplash

Monkey Sort is based on Infinite Monkey Theorem:

The infinite monkey theorem is a popular demonstration of the mathematical probability, stating a monkey hitting keys at random on a typewriter keyboard, given enough time and typewriters, will eventually reproduce the entire works of William Shakespeare. …

Design Patterns: Observer Pattern

Observer Pattern defines one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.

Aside from formal definition, Observer Pattern helps us to listen (subscribe) to a subject and be up-to-date whenever a change occurs.

Subjects are open for the Observers to subscribe, and does not know (nor care about) how they are implemented and vice versa.

Simple Example:

Suppose you are building a social media app and implementing it for multiple platforms.

a platform enum (for the sake of simplicity)

public enum Platform {

a view interface that has a display…

Design Patterns: Decorator Pattern

Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.”

Aside from formal definition, Decorator Pattern wraps around an object of a Decorator class, allowing you to dynamically change the behavior of an object at client code.

Simple Example:

Suppose you own a local pizza shop.

Of course you have menus with fixed prices, but you also have a “have-it-your-way” style pizza that allows customers to add whatever ingredient they want.

You calculated the costs of them all by yourself with a piece of paper and a pen, but now your business is growing larger and you can’t catch up anymore. …

Design Patterns: Strategy Pattern

Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use them.”

Aside from formal definition, Strategy Patterns are widely used when you need to switch your algorithm or strategy in different places of your code.

Simple Example:

Suppose you build a game that has a Cat class that implements a Diet class. But let’s say your cat gained too much weight and now it needs to go on a diet that will help it lose weight for its health.

In this case, you can implement a Strategy Pattern such…


Emre Tanriverdi

Software Engineer @Trendyol

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store