Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

227
Visualizações
Mongodb bulk.insert issues with db and concurrent response from db

I've developed a multi user app where I can login and upload a csv file. The data is extracted from the csv file into objects (about 10000) and then the data/object(s) is/are inserted into mongodb. I've tried differnt mongodb insert option. The fastest is the bulk.insert option. It inserts about 200 objects per second. Following is my bulk.insert code:

        const bulk = db.collection('mycollection').initializeUnorderedBulkOp();
        bulk.insert(csvData);
        bulk.execute();

But the issue with this bulk insert is that while data is inserted to mongodb I cannot view other pages (the pages that read data from the same db). Also, other users cannot login to the website. The website has just one db with different collections.

I tried normal insert option also. Following is the code:

await db.collection("mycollection").insert(csvData);

With this option, other users can login, I can view other pages. But, the insert speed is some 9 times slower (About 24 inserts per second).

With bulk operation, it seems, while mongodb is busy with one query, it does not respond to other queries. Please suggest me a way to increase insert speed and at the same time make the db accessible to others.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda