Comments (2)
Thanks for offering to give this a shot!
The thing is, the add-on code is pretty thin. To make it support concurrency, you'd have to reach into the core Annoy C++ code itself, which would basically mean forking from Annoy.
I don't want to do that, but here is a strategy you can use to support concurrency:
- Create multiple Node processes, each with an Annoy index.
- Have another Node process (or something like pm2 or maybe ha-proxy) route search requests to them.
This way, only when all of the processes are busy will there be any blocking. It's similar to the way UWSGI achieves concurrency - just balancing requests across child processes.
All that said, if you haven't already, I recommend you first test with a single instance to make sure that it's not fast enough. Annoy can perform between 100 and 10,000 queries per second on a large AWS instance. Depending on your traffic, it might be fine, while remaining simple.
from annoy-node.
Now, that I see this again, I think it's more accurate to say that we wouldn't need to fork from Annoy, but we would have to put threading code in the add-on that would use a pool of indexes. Overall, I think it would be less failure-prone to do that kind of rotating through the pool at the process level using the strategy above.
from annoy-node.
Related Issues (10)
- [request] support for windows HOT 2
- Support for Node 14 HOT 1
- Please Add Documentation for errors HOT 1
- Segmentation fault HOT 4
- What is the behaviour of feeding an array of Strings (of numbers)
- [request] Add support for 'unbuild()' HOT 3
- Update annoy version HOT 1
- Killed: 9 HOT 10
- node v12 error: too few arguments to function call, expected 2, have 1 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from annoy-node.