Closed beshoo closed 5 years ago
@beshoo thanks a lot you are absolutely right about scaling and proposed solutions! Technically I can using the NodeRedis wrapper to cache queries. For this I'm start building FasttextServe as a integrated solution of
And considering your suggestions I will have a loook at PM2 as process manager tool
Thank you so much for this kindly support , any plan for Cluster Module ? which will help a lot if you have very busy server.
Well i am planning to make a FREE api for fastText , in order to provide gender detection , now this will lead to a huge GET request to the server.
As you know , node only use one CORE of the CPU , here with Cluster Module we can support all CPU capacity , i am sure it is not that hard to implement base on the source thats i provide in my previous post.
Kindly Regards
@beshoo yes it makes sense. The cluster / worker will be available in the FastTextServe as well, thanks for mentioning I have forget to include in the features above. Basically you will get as many workers as many processors you have, node will automatically share the http connection among them. By the default the cluster
node.js package handles the workers in a round robin approach to serve incoming requests.
I hope that will be easy to install :) In main time what i do to check if node running with fastetxt is this :
#!/bin/bash
while true
do
gender_port_connection=`nc -z localhost 3030`
gender_port_id=`ps auxf | grep 'examples/data/gender.bin' | grep -v grep | awk {'print $2'}`
gender_bin=`ps auxf | grep 'fasttext.js/examples/gender.js' | grep -v grep | awk {'print $2'}`
gender_wget=`wget -qO- -T 2 http://localhost:3030/?text=yaren`
if [ -z "$gender_port_connection" ] || [ -z "$gender_port_id" ] || [ -z "$gender_wget" ] || [ -z "$gender_bin" ]; then
kill -9 $gender_port_id $gender_bin > /dev/null 2>&1
/usr/local/bin/node boot/gender/fasttext.js/examples/gender.js & > /dev/null 2>&1
sleep 10
fi
sleep 3
done
Because a lot of time node sometime is working , but not fasttext , and even sometimes port is opened and listening (gender_port_connection=nc -z localhost 3030
) but fasttext is not responding at all !
so the ONLY way i found is to kill and restart! I am not sure , if PM2 will help in this case , i have VERY busy server i mean by VERY , sometimes more than 4000 request to the local host same time!
So i am sharing with you my experience with this wonderful API ,
PS: i already have Memcached installed and the Memcached php add on , i am not sure if that will be conflict with " NodeRedis " will i think not , but seeking for your advice !
@loretoparisi as i can see https://github.com/loretoparisi/FasttextServe created since 3 months , is it will take long time to see the light ! i can not wait to Test and enjoy your wonderful genius code :)
@beshoo you are right, we will have something new next week stay tuned!
2 weeks passed :+1: :D
Node.js Cluster Module Node.js has implementation the core cluster modules, that allowing applications to run on more than one core.
Cluster module a parent/master process can be forked in any number of child/worker processes and communicate with them sending messages via IPC communication.
Moreover if we support caching process, by Redis which is more complex version of Memcached.
Redis always served and modified data in the server’s main memory. The impact is system will quickly retrieve data that will be needed. It also reduces time to open web pages and make your site faster. Redis works to help and improve load performance
Using Redis we can store cache using SET and GET, besides that redis also can work with complex type data like Lists, Sets, ordered data structures, and so forth.
And we can work with Node.js clustering with PM2
PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks. One of its nicer features is an automatic use of Node’s Cluster API. PM2 gives your application the ability to be run as multiple processes, without any code modifications.
I hope this may interest you to add this wonderful methods to this wonderful API
Source : https://goo.gl/MMDe3m