php - How to setup HTTP server with nodejs for logging? -
i need setup logging service startup. , team not have time , resources (monetary) deploy dedicated tool logs. need run analytics on user behavior. while going learn analytics bit , implement down line, need log user activity can pull out data later , math.
i using sql based (rdbms) setup main application (which web service) , plan log user activity in dynamodb (aws).
also, plan setup local (on same server) node.js server can handle log requests coming php based app to make sure logging activity runs in process , handled gracefully without crashing or slowing down main server code. idea here - when request comes in user, php application make call nodejs server. nodejs server take request , return immediately while queuing request (like 200 other requests) , php app continue serve request. nodejs server go on logging in queue 1 after other.
the reason why plan - nodejs runs on single thread , event-loop based - hence, in case there sudden traffic spike, log requests queued , data sent dynamo without making php application wait confirmation.
note: when user activity, mean application-level logging like:
- user x a.b.c.d ip address tried access article id 123 @ 2016-09-10 14:21:22
- user y posted comment #234 on article #987 @ 2016-09-10 18:30:02 using abc app.
- user c logged in web interface e.f.g.h ip address.
of course, data in json format , server make calls aws sdk.
here, nodejs server acting log-proxy. based on idea/scenario far, have following questions:
- is decision use dynamodb logging requests okay or making mistake? service fits within budget.
- what kind of limitations have nodejs in scenario? nodejs okay it?
- what node modules should use this? http server or there modules openly available made such scenarios?
- how make sure server listens requests coming same machine (loopback)?
here go tl;dr; answer:
1 - decision use dynamodb logging requests okay or making mistake? service fits within budget.
dynamodb nosql database service provides fast , predictable performance seamless scalability, imo it's way use when talk loggin, expected need fast writing , fast reading, without relationship between logs messages (i think). can use dynamodb without problems here.
2 - kind of limitations have nodejs in scenario? nodejs okay it?
nodejs (as said) single thread , event-loop based, if have more requests nodejs can handle with, should fork or something like
i still think should use tool logstash if sure can use nodejs that, have success.
3 - node modules should use this? http server or there modules openly available made such scenarios?
when talk logging strategies, first thing coming in mind "thousands of packages on network", don't know if have in startup, anyway suggest use udp send logg messages, udp (user datagram protocol) used establishing low-latency , loss tolerating connections between applications on internet. can startup udp nodejs listener using, for example dgram. send udp log messages nodejs server, can use winston loggin library winston-udp plugin. or, in case, php server, can send udp messages socket or take here. disclaimer: i'm not specialist in php, googled , found these solutions send log messages on udp, i'm not sure if best way :)
4 - how make sure server listens requests coming same machine (loopback)?
you can using security group
hope these help.
Comments
Post a Comment