Storing gps data

755 views
Skip to first unread message

Stuart

unread,
Mar 11, 2010, 4:51:29 PM3/11/10
to mongodb-user
For a vehicle gps tracking system, I am wondering how best to separate
the data by vehicle.

Should I go for one collection per vehicle, or one collection for all
vehicles with a field that indexes the vehicle id?

Suppose I have 1000 vehicles, each with a new gps location every 30
seconds. I will want to be able to query the database, and say pull
out the gps location of 30 vehicles with a given date range.

I will also need to be able to find the last known location of all
vehicles, as fast as possible. This would normally be held in RAM,
but after a software restart, I need to pull that data back in.

Eliot Horowitz

unread,
Mar 11, 2010, 9:41:33 PM3/11/10
to mongod...@googlegroups.com
I think one collection with a vehicle_id field would be best.

> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to mongodb-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>
>

henrik

unread,
Mar 12, 2010, 4:15:18 AM3/12/10
to mongodb-user
i'm using one collection for all the vehicle data (with vehicle id)
and one collection for the vehicles to store data that changes less
frequently which works pretty well. i'm also storing the latest data
in a redis database (see http://code.google.com/p/redis/) for very
fast access.

Eliot Horowitz

unread,
Mar 12, 2010, 7:10:50 AM3/12/10
to mongod...@googlegroups.com
Sounds good
I would try mongo for the latest data if you do _id lookups it's the
same speed as redis. So you can store your vehicle id in _id

Stuart Johnson

unread,
Apr 11, 2013, 4:16:25 PM4/11/13
to GPS-Guy, mongod...@googlegroups.com
Hi, yes I did. In fact it's come a long way since then.  Complete GPS Tracking solution, that supports 1000's of vehicles, and smartphones, and map clients running on a cluster of Mono C# backends.  Plus a 3 server MongoDB replica set, across 3 datacenters.

I used a single collection. and three fields:

1) _id field, with the date/time changed to reflect the GPS date/time.
2) Vehicle ID (typically the IMEI number)
3) A Protocol Buffer binary field, that stores all the data in compressed form (lat/lon, speed, battery level, events, IO's etc)

I have a collection index that indexs fields 2, followed by 1.

With 70 million records, I can pull out a vehicles movements for a 24hr period, and extract all the journeys it's made in a blink of an eye.

I said I needed to locate all the vehicles last known whereabouts, when the software is restarted. Multiple threads on startup query for that data, although now that never happens as the system is fully replicated across the servers, so on startup, a snapshot is pulled from another server in the cluster.

I used to use mySQL for this, and I am glad I switched to Mongo.

Stuart.

On 11/04/13 20:03, GPS-Guy wrote:
Hi Stuart,
  I was wondering if you ever implemented this project? 
Thanks,
Al
Reply all
Reply to author
Forward
0 new messages