Skip to content

Instantly share code, notes, and snippets.

View InKolev's full-sized avatar

Ivan Kolev InKolev

  • Bulgaria
View GitHub Profile

Multi-tenant systems

Check if the observed behavior is the same for other tenants, not just for a single one. The wider the dataset, the easier it becomes to isolate the probem.

Check for data bleed accross tenants

  • Configuration mix
  • HTTP requests routed to the wrong tenant
  • Message bus listeners consuming and processing data for the wrong tenant or for more than 1 tenants.

Find largest files on disk (where size is bigger than 100MB)

sudo find / -xdev -type f -size +100M -exec du -sh {} ';' | sort -rh | head -n50

PM2 node process manager

pm2 start ecosystem.config.js

Sample ecosystem file

Conway's law

"Any organization that designs a system, will produce a design
whose structure is a copy of the organization's communication structure."

Jimmy's law

"A broken, dysfunctional organization, driven by meeting unhealthy goals and metrics
will produce broken, dysfunctional systems, even if the developers in that organization are good."

Kosh (Babylon 5)

"The avalanche has already started. It is too late for the pebbles to vote."

Bet Settlement Worker (x1)

  • 40-50k items per minute (3000 cursor size, 1000 concurrency counter, 500 batch size, 250 ms timeout)

Account Operation Workers (x6)

  • 25-45k items per minute (with 3ms SQL Delay)
  • 30-50k items per minute (with 0ms SQL Delay)

Combo Bonus Workers (x6) (Slowest)

  • 18-40k items per minute (with 3ms SQL Delay)
  • 25-45k items per minute (with 0ms SQL Delay

Building Kafka from the Hardware - up

  • Higher Message Retention ? - Increase disk size
  • Higher Message Throughput ? - Increase network capacity
  • Higher Producer Performance ? - Increase Disk I/O speed
  • Higher Consumer Performance ? - Increase Memory

Critical Configurations (Consumer)

  • queued.min.messages
  • fetch.wait.max.ms
  • socket.blocking.max.ms
  1. Get authorization token POST
    http://craftcluster/api/FacebookLogin/GetAuthorizationToken?facebookAccessToken=...&facebookProfileId=...

Local IP addresses

Kafka: 172.18.0.4
Zookeeper: 172.18.0.2

Useful commands

  • Create a topic named integration-test-topic with two partitions:

    • kafka-topics --create --zookeeper 172.18.0.2:3001 --replication-factor 1 --partitions 2 --topic integration-test-topic
  • Check topic information:

  • kafka-topics --zookeeper 172.18.0.2:3001 --describe --topic integration-test-topic

Memory Management in .NET

"If you don't ultimately have a root reference, then you can't be accessed, so you must die."

Brief overview

SOH:

  • Allocates objects smaller than 85K
  • Objects are allocated on top of each other, a Next Object Pointer (NOP) represents the location where the next object will be allocated.
  • Because the NOP position is known, a new object can be immediately allocated without the overhead of looking for space in a Free Space tables.

Unit testing - Brief overview

The definition of a unit test (by Roy Osherove)

Prerequisites

A unit of work is the sum of actions that take place between the invocation of a public method in the system and a single noticeable end result by a test of that system. A noticeable end result can be observed without looking at the internal state of the system and only through its public APIs and behavior. An end result is any of the following:

  • The invoked public method returns a value (a function that’s not void).
  • There’s a noticeable change to the state or behavior of the system before and after invocation that can be determined without interrogating private state.
  • There’s a callout to a third-party system over which the test has no control, and that third-party system doesn’t return any value, or any return value from that system is ignored. (Example: calling a third-party logging system that was not written by you and you don’t have the source to.)

Unstage all files staged for commit

  • Command
git reset HEAD -- .

Revert to previous commit, discarding all changes made locally

  • Command
git reset --hard HEAD