I am using AWS, nginx server. If I update or create data in mongodb using nodejs api the data is storing and I am getting the success response.. But when I am trying to get data through postman it's returning old data. and that data is getting updated after 15 or 20 min later. But if I check data through using Sudo mongo the updated data is showing.. Why this problem is happening.. Please give me a solution if any one knows..The down image is nginx configured file
Related
I am testing postgresql with a nodejs backend server, using Pg npm module to query the database. The issue I am having is that when I run a particular query directly on the postgres database table using query tool on pgAdmin4, the data is fetched within 5 seconds. But the same query when requested from the backend through my nodejs server, the process is split between parallel workers and a client backend using IPC: messagequeuesend, this runs for almost 17minutes before return the data. I can't understand why the same query is fast using query tool, it just processes it fast but the one coming from my server has to delay. Is there a way to increase the priority for queries coming from backend to run like it was queried inside pgAdmin. I noticed when I check pg_stat_activity, there is an application value for the query when using query tool, but when the same query comes from the nodejs server the application value is null. I do not seem to understand why its like this, i have been searching every community for answers to this for the past 5 days, and there is no question or answer for this. Please any help will be appreciated. Thanks in advance
I tried running a query from the backend, but its split using IPC processes and result comes in after 17 minutes, the same query takes only 5 seconds to return a result inside pgAdmin query tool
Our rest API is a Node.js. There are few large data requests like 50 -100mb of data. So when I do post request locally i was able to get data. But when I deploy in apache servers and try to post then I get could not get any response within a minute. The time usually takes to fetch that huge data is a minimum of 4 mins. But on apache servers, it fails below minute and instances start restarting. I thought it was js heap out of memory so in package JSON I updated node --max_old_space_size=8092 --stack-size=85500 server.js this way.
From then I didn't get any memory error both local & in staging. Any idea where am I going wrong when deployed in servers.
Note - when requested for other data like small data it was fine.
Issue
I have an Express (Node.JS) + MongoDB app with a server response load time of 4 - 7 seconds on average (slow).
I understand that the average server response time is under 200ms as per google pagespeed tools.
This app is fetching data from a mongoDB asynchronously but the roundtrip times to the database is extremely slow with each call averaging about 500ms - 1s. These calls are simple findAll calls to retrieve data of less than < 100 records.
Context
Mongoose version: 4.13.14
DB server's MongoDB version is 3.4.16
DB server is hosted on MongoDB Atlas M10 in AWS / Oregon (us-west-1)
Web server is hosted with now.sh in SFO1 (us-west-1)
Have performed recommended indexes as advised by MongoDB Atlas's performance advisor
Data fetching perfectly fine in local environment (local server + local db) as data is queried in a matter of few ms
Mongoose logs for the affected page can be found in this gist
Mongo Server configuration
Mongo Atlas M10
2GB Ram
10 GB Storage
100 IOPS
Encrypted
Auto-expand storage
Attempted solutions:
I have checked my DB metrics, they looked fine. There are also no slow queries. These are simple findAll queries. Performance advisor on mongo atlas reports nothing unusual.
The production application and database are both hosted in the same region.
I have already tried optimising the application layer of the query (mongoose) by running .lean()
Question:
Where else should i look to improve the database latency? How can a simple query take so long? Otherwise, why is my server response time taking up to 4s when the expected is about 200ms?
Hey you can try hosting your server and database in the same region. I think the network is creating a overhead in this case. If the server and the database are in the same region, They are on the same network which will reduce the latency significantly. there is a diagram on aws for this
I add some problem like yours with an app that i developed in my master degree. I add to put a node.js api running online to present it in class room.And i realized that every time i wanted to make a call in the api the response was taking allot of time. I realized that one of the problems was the school network because of the firewalls. Also the place where i put the server heroku.com was giving some delay as well. What i did was use Redis ( https://redis.io/ ) to improve the performance, also heroku was giving me some problems because of the requests being http and not https.
Make a test running the app and data on your localhost and see the performance. if you donĀ“t have any issue try to check if nothing is messing with your request like the place where you host your node server.
Let me know if this helps or if you still have issues so i can try to help you out better.
I had the same issue once with my nodejs code using the same development stack(mongodb,nodejs), I got into trouble of late response from api, and after spending a lot of time I found my server the real culprit I then changed from heroku to amazon aws EC2 instance and things started working fast and amazingly fast, so probably
your web server is culprit
to make sure mongodb is not culprit, write an api endpoint where you can just return some json response without making any query to database.
I'm using Angular6, PostgreSQL and sequelize-typescript. The goal is to connect to a DB and get a list of names and ages into a table.
I started by creating an Express server.
I then used sequelize-typescript to connect to my PostgreSQL DB and call this connection when initializing server
I created a model of my data element using sequelize-typescript and using it to connect to my PosgreSQL DB.
I then created a simple route to the data using Express Router
I added the route to the initial Express Server
This all seemed to work (albeit messy as I'm learning as I go). But I can reach my local server through the browser (localhost:3000) and use PostMan to get the data from the DB (localhost:3000/people).
Client side:
I already have the initial front-end app that was created with I ng'ed the project using command line. I can reach this at (localhost:4200)
I created a simple component called people using ng g component people.
How do I get the data from my server route into the client component? I believe it's through HTTP and then subscribe but there seems to be a lot of different ways to do this. I'm looking for advice on the best pattern to use in Angular6.
TL;DR How do I get the data from my route to the front end
I finally got it working correctly, I needed to create a service that listened to the API url and from there I could return the observable to the component.
The solution (even though it's not cleaned up properly) sits at:
https://github.com/micklynch/travelbudget
I am having a problem with retrieving values from my rethinkdb database and exposing them in my API.
Everything is running without errors, but I get different results when querying the database with python then the API.
I have created the database, tables and inserted data with REPL queries in python.
My setup is like this:
- AWS ec2 (Ubuntu)
- Rethinkdb as database
- Node API: clone of https://github.com/yoonic/atlas
I have no clue why there is a difference or where to look next for debugging.
Any help to get me going is appreciated!