APPLICATION OF DATA SHARDING AND REPLICATION IN A DISTRIBUTED DATABASE: A MONGODB PROOF OF CONCEPT
Abstract
This study presents a proof of concept of a distributed MongoDB database employing sharding, replication, and Docker containers. It is an applied, experimental study with a quantitative approach. The environment was deployed on a single machine, with two shards, each composed of a three-member replica set, three config servers, and a mongos router, totaling ten containers. A total of 10,000 documents were inserted into a collection hash-sharded on the _id field, and the distribution was verified using MongoDB commands. Five interruption tests of the primary member were then performed, all on the same replica set (rsShard1), monitoring the time until a new primary was identified by the observer and the write operations executed in parallel. The observed distribution was 4,994 documents in one shard and 5,006 in the other. The time until the identification of a new primary by the observer, a metric that includes observation overhead, was 10.57 ± 0.76 s (mean ± standard deviation; median 10.56 s). In all tests, at least one insert operation reached the affected shard during the transition and completed with elevated duration (8.3 to 10.7 s); in two of them, a transient connection failure (608 and 623 ms) occurred on the immediately preceding attempt. The results characterize the architecture's behavior in the local environment used, but do not demonstrate improved query performance or tolerance to physical failures of the host machine.
Author Biographies
University of Araraquara, undergraduate student in Information Systems.
University of São Paulo, PhD in Software Engineering.
References
AMAZON WEB SERVICES (AWS). O que é NoSQL? [S. l.]: AWS, 2026a. Disponível em: https://aws.amazon.com/pt/nosql/ Acesso em: 9 maio 2026.
AMAZON WEB SERVICES (AWS). Qual é a diferença entre imagens e contêineres do Docker? [S. l.]: AWS, 2026b. Disponível em: https://aws.amazon.com/pt/compare/the-difference-between-docker-images-and-containers/ Acesso em: 15 maio 2026.
BREWER, Eric. CAP twelve years later: how the "rules" have changed. Computer, Los Alamitos, v. 45, n. 2, p. 23-29, Feb. 2012. DOI: https://doi.org/10.1109/MC.2012.37 DOI: https://doi.org/10.1109/MC.2012.37
COULOURIS, George; DOLLIMORE, Jean; KINDBERG, Tim; BLAIR, Gordon. Sistemas distribuídos: conceitos e projeto. 5. ed. Porto Alegre: Bookman, 2013.
DOCKER. Docker Docs. [S. l.]: Docker, 2026. Disponível em: https://docs.docker.com/ Acesso em: 15 maio 2026.
ELMASRI, Ramez; NAVATHE, Shamkant B. Sistemas de banco de dados. 7. ed. São Paulo: Pearson Education do Brasil, 2018.
GILBERT, Seth; LYNCH, Nancy. Brewer's conjecture and the feasibility of consistent, available, partition-tolerant web services. ACM SIGACT News, New York, v. 33, n. 2, p. 51-59, 2002. DOI: https://doi.org/10.1145/564585.564601 DOI: https://doi.org/10.1145/564585.564601
KLEPPMANN, Martin. Designing data-intensive applications: the big ideas behind reliable, scalable, and maintainable systems. Sebastopol: O'Reilly Media, 2017.
MONGODB. Balanceador de cluster fragmentado. [S. l.]: MongoDB, 2026a. Disponível em: https://www.mongodb.com/pt-br/docs/manual/core/sharding-balancer-administration/ Acesso em: 11 out. 2026.
MONGODB. Chaves de fragmentação. [S. l.]: MongoDB, 2026b. Disponível em: https://www.mongodb.com/pt-br/docs/manual/core/sharding-shard-key/ Acesso em: 9 set. 2026.
MONGODB. Config Servers. [S. l.]: MongoDB, 2026c. Disponível em: https://www.mongodb.com/pt-br/docs/manual/core/sharded-cluster-config-servers/ Acesso em: 14 ago. 2026.
MONGODB. Database Scaling. [S. l.]: MongoDB, 2026d. Disponível em: https://www.mongodb.com/resources/basics/scaling Acesso em: 13 maio 2026.
MONGODB. Eleições do conjunto de réplicas. [S. l.]: MongoDB, 2026e. Disponível em: https://www.mongodb.com/pt-br/docs/manual/core/replica-set-elections/ Acesso em: 12 out. 2026.
MONGODB. Fragmentação. [S. l.]: MongoDB, 2026f. Disponível em: https://www.mongodb.com/pt-br/docs/manual/sharding/ Acesso em: 12 abr. 2026.
MONGODB. Hashed sharding. [S. l.]: MongoDB, 2026g. Disponível em: https://www.mongodb.com/docs/manual/core/hashed-sharding/ Acesso em: 31 out. 2026.
MONGODB. Partição de dados com blocos. [S. l.]: MongoDB, 2026h. Disponível em: https://www.mongodb.com/pt-br/docs/manual/core/sharding-data-partitioning/ Acesso em: 11 out. 2026.
MONGODB. Replicação. [S. l.]: MongoDB, 2026i. Disponível em: https://www.mongodb.com/pt-br/docs/manual/replication/ Acesso em: 13 maio 2026.
MONGODB. Retryable Writes. [S. l.]: MongoDB, 2026j. Disponível em: https://www.mongodb.com/docs/manual/core/retryable-writes/ Acesso em: 31 out. 2026.
MONGODB. Roteamento com mongos. [S. l.]: MongoDB, 2026k. Disponível em: https://www.mongodb.com/pt-br/docs/manual/core/sharded-cluster-query-router/ Acesso em: 14 ago. 2026.
MONGODB. Write Concern. [S. l.]: MongoDB, 2026l. Disponível em: https://www.mongodb.com/docs/manual/reference/write-concern/ Acesso em: 31 out. 2026.
ONGARO, Diego; OUSTERHOUT, John. In search of an understandable consensus algorithm. In: USENIX ANNUAL TECHNICAL CONFERENCE, 2014, Philadelphia. Proceedings [...]. Berkeley: USENIX Association, 2014. p. 305-319. Disponível em: https://www.usenix.org/conference/atc14/technical-sessions/presentation/ongaro Acesso em: 1 nov. 2026.
RIBEIRO, Victor Aparecido; SILVA, Vinicius Alcará da; SILVA, Luis Alexandre da. Replicação de banco de dados: cluster em ambiente na nuvem com MongoDB. Revista EduFatec, Franca, v. 1, n. 4, 2021. Disponível em: https://ric.cps.sp.gov.br/bitstream/123456789/8435/1/edufatec-n04v1a02.pdf Acesso em: 12 abr. 2026.
SCHULTZ, William; AVITABILE, Tess; CABRAL, Alyson. Tunable consistency in MongoDB. Proceedings of the VLDB Endowment, [S. l.], v. 12, n. 12, p. 2071-2081, 2019. Disponível em: https://vldb.org/pvldb/vol12/p2071-schultz.pdf Acesso em: 31 out. 2026. DOI: https://doi.org/10.14778/3352063.3352125
ZHOU, Siyuan; MU, Shuai. Fault-tolerant replication with pull-based consensus in MongoDB. In: USENIX SYMPOSIUM ON NETWORKED SYSTEMS DESIGN AND IMPLEMENTATION, 18., 2021, [S. l.]. Proceedings [...]. Berkeley: USENIX Association, 2021. p. 687-703. Disponível em: https://www.usenix.org/conference/nsdi21/presentation/zhou Acesso em: 31 out. 2026.
