What is the most scalable and cost effective solution to track vehicle locations realtime?

We need to build an app which will track vehicles in real time like Uber. Our back end is built with Node and the database is PostgreSQL. There can be thousands of vehicles trying to update their location in real time. We also need to track the user’s online and offline status.

One solution is to use Firebase to store the location information and listen to them in the serverside and update the online-offline status in the database.

Another solution is to write a separate module with something like MongoDB, CouchDB and use sockets to update the data in real time.

We need something that will scale well and be cost effective.