How to use 2 database servers for a rails application

Viewed 65

I have to develop a data management system so that the my all digital information(like pdf or docs) i will scan and store in one database and the reference unique key for the digital documents will save on different database with the created users information. One mysql database I already created for storing created users information and document related information. But to scan and store the pdf data as digital records what is the best way i can do with second db?. Can i use a different mysql db for this. what db shall i use? is it possible to work with 2 databases in a ruby application in this case. whether the 2 database concepts be success in this case?. Will it make the application slow?. I want the application to run faster when i try to fetch records. Or with one database only any way to make it work faster?. i don't have a idea to do this. can anyone suggest an idea for this.

1 Answers

Most people who handle content like scanned documents put the documents into ordinary web servers or CDNs using hard-to-guess (random) file names, and put the file paths into MySQL or whatever RDBMS they use.

Why? a few reasons:

  • RDBMSs aren't great at streaming binary large objects (BLOBs) to users. Plain Old Web Servers are. For example, Apache and Linux have grown up together and do this astonishingly efficiently. nginx is also good.
  • When scaling up, you don't want to make your RDBMS the bottleneck for delivering that content to users, whether or not it's the same one you use for transactional stuff.
  • A simple CDN is just an Apache or nginx web file server. But those scale out almost magically easily using cloud vendors' networks. Spend a few hundred dollars with CloudSomething and boom, you're global.

An ordinarily file-serving web server will do a great job of this until you need to scale it up.

Security: do not name your files 1.pdf, 2.pdf, and so forth. Make them really hard to guess. Lest you end up on KrebsOnSecurity.com

Related