Skip to content

Instantly share code, notes, and snippets.

@gc-garcol
gc-garcol / raft.md
Last active July 18, 2024 09:52
Raft protocol

RAFT

Replicated state machine

image
  • Replicated state machines are typically implemented using a replicated log.
  • Each server stores a log containing a series of commands, which its state machine executes in order.
@gc-garcol
gc-garcol / dockerfile-java.md
Created July 17, 2024 16:00
build optimize dockerfile java
@gc-garcol
gc-garcol / distributed-design-pattern.md
Created July 10, 2024 01:54
distributed design pattern
@gc-garcol
gc-garcol / data-race-n-race-condition.md
Last active July 9, 2024 15:08
race data vs race condition

Race data example

The result is 11, 12, or 13

// balance = 10
public void deposit(int amount) {
  balance += amount;
}
@gc-garcol
gc-garcol / java-off-heap-database.md
Last active July 3, 2024 14:11
java-off-heap-database

java-off-heap-database

Java NIO ByteBuffer class

  • Cấp phát bộ nhớ cho ByteBuffer sử dụng method là allocateDirect (thay vì allocate), khi xài method này thì Java sẽ gọi thẳng tới lệnh cấp phát bộ nhớ từ OS, và bộ nhớ được cấp phát sẽ không nằm trong sự quản lí của Java Heap Space cũng như Java GC.
Person person = new Person();
//…
@gc-garcol
gc-garcol / lmax-disruptor.md
Last active July 1, 2024 04:16
LMAX disruptor
@gc-garcol
gc-garcol / benchmark-tools.md
Last active July 15, 2024 01:35
Benchmark tools