Khalil Tahraoui-

Engineering Robust Systems

Building an Adaptive IPFS-Based Distributed Storage System

I started building a distributed storage system inspired by IPFS to understand how content-addressed networks behave under real load conditions.

At first, everything worked correctly in controlled environments. Data was stored, retrieved, and replicated as expected. The issues only appeared during load testing, when the system was exposed to unstable networks, uneven access patterns, and variable node behavior.


Problems encountered

During load testing, three main issues consistently appeared.

Peer behavior in the network was inconsistent, but the system treated all peers equally.

Storage distribution became unbalanced over time, with certain blocks receiving significantly more requests than others.

The consistency model was fixed, which caused inefficiencies under both low and high request loads.


Fixing the system with adaptive algorithms

Adaptive peer selection

The system selected peers without considering latency or reliability, which led to inconsistent response times during load testing.

I introduced a scoring mechanism that evaluates each peer based on latency and failure rate. Peer selection is now dynamic and continuously adapts based on real-time conditions.

Technologies: Go, IPFS, custom routing layer

type Peer struct {
	ID      string
	Latency float64
	Fail    int
}

func score(p Peer) float64 {
	return (1/(p.Latency+1))*0.7 + (1/(float64(p.Fail)+1))*0.3
}

func selectPeer(peers []Peer) Peer {
	best := peers[0]
	bestScore := score(best)

	for _, p := range peers {
		s := score(p)
		if s > bestScore {
			best = p
			bestScore = s
		}
	}
	return best
}

Adaptive replication and load balancing

During load testing, some blocks became significantly more accessed than others, creating uneven pressure across nodes.

I implemented adaptive replication based on access frequency and node load. Frequently accessed blocks are replicated more widely, while less accessed data is gradually reduced. When a node becomes overloaded, blocks are migrated to less loaded nodes.

Technologies: IPFS, distributed storage layer, monitoring system

def adjust_replication(block):
    if block.access_count > HOT_THRESHOLD:
        block.replication += 2
    elif block.access_count < COLD_THRESHOLD:
        block.replication = max(1, block.replication - 1)

def rebalance(nodes):
    for node in nodes:
        if node.load > 0.8:
            migrate_blocks(node)

Adaptive consistency control

The system used a fixed consistency model, which created inefficiencies under different load testing conditions.

I introduced adaptive consistency control that adjusts behavior based on current system load. Under high load, the system relaxes consistency requirements to maintain responsiveness. Under normal conditions, it enforces stronger guarantees.

Technologies: Go, distributed systems, quorum-based replication

type State struct {
	Load float64
}

func consistency(state State) string {
	if state.Load > 0.8 {
		return "eventual"
	}
	if state.Load > 0.5 {
		return "quorum"
	}
	return "strong"
}

Conclusion

Building this infrastructure proved that true reliability in high-capacity distributed environments cannot rely on static configuration maps. By coupling peer matching protocols, storage replication density, and consistency rules directly to real-time performance metrics, the architecture transforms from a rigid array of machines into a self-balancing, self-healing data fabric.

I will deploy this system as soon as I finish working on my master thesis :) and never forget load testing your systems

Technologies used: Go, Python, IPFS, distributed systems design, adaptive algorithms