JSFiddle - React, Tailwind, and code Playground
by endeepak
HTML
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/src/simufast.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/main.js"></script>
<script>
simufast.run((player) => {
const consistentHash = new simufast.routing.ConsistentHash(player, {
nodeReplicationFactor: 1
});
const simulation = new simufast.cache.MultiNodeCacheSimulation(consistentHash, {
nodes: ["S1", "S2", "S3"],
});
const keys = simufast.utils.randStringArray(100);
const commands = []
for (let i = 1; i <= 300; i++) {
const key = simufast.utils.getRandomValueFromArray(keys);
commands.push(() => simulation.getOrFetch(key, () => `${key}'s value from data source`));
}
player.experiment({
name: 'Consistent Hashing(Basic): Static nodes',
drawable: simulation,
commands: commands
});
}, {
speed: 5,
maxWidth: 290,
statsExpanded: true
});
</script>