About MongoDb sharding - mongodb

I’m facing a deployment issue for my product. I have to deploy it on a couple of servers which are located on different countries. My product has 3 main components:
Application server: server and database (I'm using MongoDb)
User app: communicates with application server
Web server
Every application server can working independently. The requirements are:
The web server can access to all Databases and treat them as 1 single database.
The data of Application server 1 must be stored on its own database (not on Application server 2, or 3, or so on).
After googling around, 1 solution is deploying sharded clusters. Because I’ve never done this before, so is it a good idea? Will it meet the requirements? What points that I have to pay attention to when doing this? If it is not a good idea, please show me a good way to solve the problem.
Thank you very much.

Related

One ASP.Net application on IBM Cloud - One or more MongoDB's?

I have an ASP.NET application running IBM Cloud, and I have a MongoDB instance created, and my application is deployed in my development-space, and bound to the MongoDB(alias). All working fine.
Now, I have also created a production-space, and want to deploy the application there, after having verified it in Dev.
But - do I really have to create another MongoDB - and pay for 2 instances, or can I somehow share one instance (with security seperating that dev cant access prod)?
Or what is best practice in this case?
Any advice much appreciated.
It is your call. The connection string to the mongodb will work from both dev and prod. I would recommend having two mongodb instances. A separate dev mongodb will allow development to work in isolation both functionally, performance and security.

How to replicate a postgresql database from local to web server

I am new in the form and also new in postgresql.
Normally I use MySQL for my project but I’ve decided to start migrating towards postgresql for some valid reasons which I found in this database.
Expanding on the problem:
I need to analyze data via some mathematical formulas but in order to do this I need to get the data from the software via the API.
The software, the API and Postgresql v. 11.4 which I installed on a desktop are running on windows. So far I’ve managed to take the data via the API and import it into Postgreql.
My problem is how to transfer this data from
the local Postgresql (on the PC ) to a web Postgresql (installed in a Web server ) which is running Linux.
For example if I take the data every five minutes from software via API and put it in local db postgresql, how can I transfer this data (automatically if possible) to the db in the web server running Linux? I rejected a data dump because importing the whole db every time is not viable.
What I would like is to import only the five-minute data which gradually adds to the previous data.
I also rejected the idea of making a master - slave architecture
because not knowing the total amount of data, on the web server I have almost 2 Tb of hard disk while on the local pc I have only one hard disk that serves only to take the data and then to send it to the web server for the analysis.
Could someone please help by giving some good advice regarding how to achieve this objective?
Thanks to all for any answers.

mongodb - user connection string, secure password

I've been following a tutorial with express, node and mongo.
I have in a config file on the server side:
production:{
db:'mongodb://MYUSERNAME:MYPASSWORD#ds033307.mongolab.com:33307/dbname',
rootPath:rootPath,
port:process.env.PORT||80
}
so, i have my username and password in clear text in a server side javascript file. should i be worried about this? if yes, where else can I put it?
Thanks.
Edit: I went back and had a look at mongolab and heroku (where my site is hosted) docs.
Where I found: "The MongoLab add-on contributes one config variable to your Heroku environment: MONGOLAB_URI", and so I was able to put the MONGOLAB_URI env var into my config and move the password out of the source code.
With regards to the same datacenter, am I right to assume heroku would not be hosting my mongolab database in their datacenter, but would instead be calling out to a cloud service mongo database? Not much I can do then, is there, if I want to stick with mongolab and heroku?
I know this question is old but according to Heroku's docs they currently use 2 datacenters (https://devcenter.heroku.com/articles/regions#data-center-locations).
Their US server is 'amazon-web-services::us-east-1' and their EU alternative is 'amazon-web-services::eu-west-1'.
Both of these data centers are available when launching mongo instances on Mongolab so you can choose for both your app and your db to be on the same datacenter giving much improved security.
I think you should always be concerned about storing passwords in source code files. Generally you would be much better off keeping it in a configuration file that is managed separately. This gives you the flexibility to use the same code with a different configuration file to point to development or qa databases.
Of bigger concern perhaps - are you hosting your application in the same datacenter that MongoLab is hosting your database? If not, that user name and password, along with your data, will traverse the internet in the clear.
MongoLab does not currently support SSL (other than for their RestAPI) so even they recommend being in the same data center:
Do you support SSL?
Not yet but it is on our roadmap to be available in Summer 2014. In
the meantime, we highly recommend that you run your application and
database in the same datacenter. If you have a Dedicated plan, we also
highly recommend that you configure custom firewall rules for your
database(s).
Rest API:
Each MongoLab account comes with a REST API that can be used to access
the databases, collections and documents belonging to that account.
The API exposes most the operations you would find in the MongoDB
driver, but offers them as a RESTful interface over HTTPS.
I would definitely read MongoLab's security page fairly closely:
https://docs.mongodb.com/manual/security/

Linode + MongoHQ, or host my own DB?

Am working on a project using python/flask/mongodb, and needed to figure out the hosting/infrastructure.
Prefer to use VPS'es instead of services like Heroku.
Which in your opinion is the better option ?
a) Linode app/web server + mongoHQ
b) Linode app/web server + mongodb & replicas setup on a few Linodes
c) AWS EC2 with MongoHQ (sicne mongohq is hosted on EC2 as well)
d) Any other advisable suggestions?
I am experienced in Linux/DB in general, hence more concerned about the maintenance efforts, distracting me from delivering actual application features.
Thanks.
This is a hard question to answer as there's no correct answer to this.
This all depends on your traffic, application uptime needs and ultimately your manpower and infrastructure.
If you're a one person startup and with limited Mongo DB knowledge (ie setting up replicasets, sharding etc) then go with Mongo HQ. I have done some test instances with Heroku as the app layer and they work well enough.
As you grow it might be a good idea to hire a dedicated mongo person and/or sign up for paid 10gen support which also gives you access to their monitoring console and other goodies to help management.
My only suggestion would be to watch your queries... When generating search result pages, specify only the fields you want and need from the db... Your throughout and latency aye generally a bigger cost for queries from remote systems than execution time for a query.
Also see if MongoLab or MongoHQ have in site or hosting from a priority connection to your vps site of choice.
Having managed db hosting can be a really nice thing.

What should I consider when deploying a new web farm?

My web app has been chugging along just great in Production for years with one App server and one Web server. Now we're moving to a multi-server environment with 2 App and 3 Web servers. I have enough time to make changes before the go-live.
As a Developer, what considerations should I take into account from coding, deployment, and architectural/ecosystem management perspectives?
Already on my list:
Remove tight-coupling between servers
Applicable files (i.e. downloadables) stored in IMAGE fields in SQL instead of files on app server
Deployment: Take out node out of the farm at a time
Have you given any thought to sticky sessions and cache management?