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

download specific dbs #19

Closed
atlanteh opened this issue Jan 22, 2022 · 9 comments · Fixed by #20
Closed

download specific dbs #19

atlanteh opened this issue Jan 22, 2022 · 9 comments · Fixed by #20

Comments

@atlanteh
Copy link
Contributor

Hey, is there a way to only download a specific database and not all them?

@GitSquared
Copy link
Owner

No, this is not currently supported. Could you tell me a bit more about your usecase for this?

@atlanteh
Copy link
Contributor Author

Thanks for the super fast reply!
Well I only need the country iso_code to redirect the user to the right place based on that so I don't need the rest of the dbs..
I don't want to give the container any write access to any persistence for security reasons, so I want it to write to in memory "/tmp" but the city db would take a lot of memory without me needing it..

@GitSquared
Copy link
Owner

Thanks for the explanation. Downloading only the country DB would save you about 37MB tops, which is really negligible on most systems those days, so I'm not entirely convinced it's worth adding a new feature for. Are you working in an IoT context?

@atlanteh
Copy link
Contributor Author

@GitSquared actually on my computer I'm seeing different values
City is 70MB
ASN is 7MB
Country is 5.5MB
image

I don't feel this is negligible. I'm not using IOT, but I'm working on an app that should consume a lot of memory, and should be very fast, so I'm trying to save up as much as possible, and saving 77MB of memory on each container just by removing these DBs sounds great to me.

Is there a reason not to implement this? I mean this feels like a basic feature request - download only what you need, no?

@GitSquared
Copy link
Owner

Sorry, you're right — I was looking at the compressed archives that the lib download, not the size of the unpacked databases.

I'm working on an app that should consume a lot of memory ... so I'm trying to save up as much as possible

Note that if you're writing data to /tmp, that's disk storage on most systems, not RAM - unless you mount your whole container in a ramdisk

Is there a reason not to implement this? I mean this feels like a basic feature request - download only what you need, no?

It is pretty basic indeed, but I haven't touched this lib in a long time and wanted to clean it up a bit, so its a bit more of an investment on my end. But I guess i'll take the opportunity to finally do that ;)

Should have something for you very soon, this week at least.

@atlanteh
Copy link
Contributor Author

atlanteh commented Jan 24, 2022

That's amazing. thank you so much!
Regarding the /tmp please have a look here:

https://aws.amazon.com/about-aws/whats-new/2018/03/amazon-ecs-adds-support-for-shm-size-and-tmpfs-parameters/

The tmpfs parameter allows you to mount a temporary volume in memory. This removes the need to store data in your container instance and allows containers to run in a read-only mode, which can improve the security of your service.

@GitSquared
Copy link
Owner

interesting, thanks for the link!

@GitSquared
Copy link
Owner

Hey — just published https://github.com/GitSquared/node-geolite2-redist/releases/tag/v3.0.0 with this feat added! You can simply open() a DB or a list of DB like ['GeoLite2-Country', 'GeoLite2-ASN'] and it'll just download what you need. Detailed examples here.

Lmk if you have any questions or trouble!

@atlanteh
Copy link
Contributor Author

Thanks so much for this awesome work!
I tested this and it works great.
The customStorageDir didn't work, so I created a quick PR:
#21

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 a pull request may close this issue.

2 participants