Mongoimport: collection mise à jour tous les soirs sans interrompre la consommation de données

StackOverflow https://stackoverflow.com/questions/8301421

  •  22-10-2019
  •  | 
  •  

Question

J'ai une collection d'environ 625 000 objets.

par nuit Cron, je récupère un fichier mis à jour (TSV) de ces données à partir d'un fournisseur de données et la nécessité de les réimporter dans mon MongoDB.

Quelle est la meilleure façon de le faire sans interrompre le site / service et ses utilisateurs qui consomment les données? Est-mongoimport --upsert directement sur la collection de la meilleure façon? Il est tellement lent.

Devrais-je penser à d'autres méthodes impliquant des copies de ma collection?

Était-ce utile?

La solution

Is mongoimport --upsert directly on the collection the best way? It's just so slow.

This will work, but in my experience mongoimport has been slow and unwieldy. It also has some other serious limitations: no ability to track progress, no spot for checking/validation, no log of what's it doing.

Should I be thinking about other methods involving copies of my collection?

The alternate method here is to write a script that does this. In most languages this is pretty trivial.

This will give you the ability to track progress and handle bad data. If you find the import particularly slow, you may also be able to fork the process and split up the work.

About speed

Do remember that you're updating 625k objects. If you can get 1k updates/second that's still 10 minutes to update. If you run mongostat or check your monitoring during the import process, you should get some idea of how much work is being done.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top