Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LBS location cache #4407

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

LBS location cache #4407

wants to merge 1 commit into from

Conversation

wupeka
Copy link

@wupeka wupeka commented Sep 30, 2019

When a device is out of GPS range (e.g. in a garage) it will send LBS location. Traccar will query the external service (Google API) to locate it with every packet, which is inefficient and can be costful.

This PR adds a simple ehcache-based cache of LBS locations.

Closes #3790

@tananaev
Copy link
Member

Please provide some information on how it's better than current cache.

@wupeka
Copy link
Author

wupeka commented Sep 30, 2019

@tananaev Is there any cache? After ~2-3 weeks of just one device sitting in my home (without GPS), sending location updates every 3 minutes, I got a bill for ~$30 for google location services. This is just a quick in-memory cache for devices that are missing GPS signals but are still regularly sending LBS/wifi updates.

@tananaev
Copy link
Member

So, you have changed the code without noticing that there is already an in-memory cache available?

@wupeka
Copy link
Author

wupeka commented Sep 30, 2019

You mean a cache for LBS locations? No, I haven't noticed that.

@tananaev
Copy link
Member

Sorry, it's available for geocoding, but I don't think we should use entirely different solution for geolocation.

@wupeka
Copy link
Author

wupeka commented Sep 30, 2019

I wanted to have a quick working solution before the bill from Google ruins me :)
I have very little experience with Java, so I looked for as out-of-the-box'ish solution to the problem as possible and ehcache seemed to fit perfectly.
The solution used for geocoding might not work here, as there's no garbage collection and no timeouts - we need to eventually get rid of old entries, and LBS data changes over time. An insert-only map would be a possible memory leak here (while it might not be a problem in most real-life cases, it definitely could be a surface attack to DoS the server - by sending a bunch of random LBS/wifi only messages).

@tananaev
Copy link
Member

It's an LRU cache.

@wupeka
Copy link
Author

wupeka commented Sep 30, 2019

OK, now I see it.
That still doesn't solve the 'old data' problem though, unless we'd add a manual 'timeout' field, and that'd complicate it even further. For me, the ehcache solution seems cleaner for this case.

@macano13
Copy link

Why you dont use a mozila LBS for free ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] LBS location cacheing
3 participants