use the following search parameters to narrow your results:
e.g.(and 'dog' reddit:'aww' site:'imgur.com')
(and 'dog' reddit:'aww' site:'imgur.com')
see the search faq for details.
advanced search: by author, community...
Ask Webdev: Website with instant notifications (self.webdev)
submitted 6 months ago by nrogers64
Let's say a client asked you to build a website that would be used internally by 1,000 or so people. The website needed to notify users of events that happen on the website and those notifications need to appear automatically, much like Facebook notifications.
Which web server would you use? I've read that Apache is not a good choice for this type of situation.
Which language would you use?
Love it or hate it, would it be possible/reasonable to accomplish this using PHP?
Thanks!
[–]vduquette 2 points3 points4 points 6 months ago
pusher
[–]zushiba[] 1 point2 points3 points 6 months ago
http://nodejs.org/
Node.js is a server-side JavaScript environment that uses an asynchronous event-driven model. This allows Node.js to get excellent performance based on the architectures of many Internet applications.
[–]nrogers64[S] 0 points1 point2 points 6 months ago
Thanks for the suggestion. Could you please be a little more specific? I'm a Apache, MySQL/PostgreSQL, (Cake)PHP guy. That's all I've ever known.
Are you saying I should create a server with Node that does nothing but handle WebSocket stuff or do the whole backend logic in Node as well or what? What would you do in this scenario? What web server and programming language would you use? I would very much appreciate the help. Thanks!
[–]zushiba[] 0 points1 point2 points 6 months ago
I wish I could give you more information but I've only dabbled in Node.js. I'm a LAMP guy myself but from what I did gather from playing with Node.js you'd probably have to do most of it in Node.js. I'm not sure how you plan on pushing notifications but you might be able to get away with an iFrame.
My project was a simple chatbox that'd be integratable via an iFrame. I didn't get very far but the capabilities of Node.js did impress me, I only quit because after some time I figured it was faster to just go with a more simple ajax implementation.
Honestly, while you could accomplish what you're looking to do with Node.js, if you're more familiar with PHP than Java you'd probably get further, faster with long polling.
Node.js's can achieve the immediate notification you're looking for. If your not looking to do anything amazingly complex it's not a bad option. I do suggest giving it a try just for fun though it is a very neat thing to play with.
OK, well thanks for the advice! I really appreciate your time.
[–]nemeth88 0 points1 point2 points 6 months ago
You probably want to use an event-based webserver (JavaScript/Node, Ruby/EventMachine, Python/Twisted) rather than a request-based server (PHP/Apache) - PHP isn't designed to work as a long-running server process, but rather is supposed to run short 1-2 second scripts that then get cleaned up when the request ends.
As an example, check out http://socket.io/ for Node.
[–]WDKevin 0 points1 point2 points 6 months ago
The server wouldn't matter a whole lot. You're going to want to use AJAX to push notifications to the user, PHP is a server side language and renders all it's code before the website is returned to the user. jQuery will probably be a friend of yours in this project as well.
[–]mikedoesweb 5 points6 points7 points 6 months ago
Um....
Ajax is not a magic bullet, and certainly will not push notifications to a user. Ajax is just a method of using javascript, which runs on the client side. What he could do with Ajax is set a timer and ask the server every x seconds if there is an update. However -- with a large number of users this would place a huge strain on the server.
OP, what you actually need to look at to truly do this is Comet, a
web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it.
or, in HTML 5, Websockets
Thanks for the advice. Which web server and language would you use if it was your project?
[–]cmwelsh 1 point2 points3 points 6 months ago
You'll want to use more than one web server. Node.js is nice for long-polling/WebSockets but something like PHP/Python/Ruby might be friendlier for designing other functions of the site.
You are looking at a pretty serious undertaking with multiple kinds of web servers to get this right. I would use WebSockets with AJAX long-polling as a fallback. http://en.wikipedia.org/wiki/WebSocket
[–]Kaz3 0 points1 point2 points 6 months ago
Isn't that what Facebook does though, use AJAX requests to get friend updates? Every 5-10 seconds it sends a new request, which I assume gets updates.
I'm considering doing something similar as the OP for a work project and I've looked into Node.js and sockets, but neither of them seem mature enough.
[–]WDKevin -1 points0 points1 point 6 months ago
AjaxPush: http://www.icefaces.org/main/ajax-java/ajaxpush.iface
[–]cheald 2 points3 points4 points 6 months ago*
Long polling is not "push". It's polling. You can't truly push anything with AJAX. The server can elect to just sit on a request until it has data to serve, which is what happens there.
If you want actual push functionality, you have to use websockets. You also need a specialized server that can handle websocket connections.
[–]jij 2 points3 points4 points 6 months ago
And with 1000 uses (assuming all at once) you better have apache set up correctly.
What settings would you recommend?
[–]MiHeath 1 point2 points3 points 6 months ago
You can do comet with PHP/ajax as documented @ http://www.zeitoun.net/articles/comet_and_php/start#comet_with_classic_ajax_litte_chat_demo ... I'm not sure 1000 users would be a straing simply using ajax though, especially if you limit how often the call is made (can probably be done every 30 seconds- minute) or even cache the contents of the php file being cached for a certain amount of time to reduce server load. Yes 1000 requests/second is a bit much, so try to avoid that scenario, but combining a few of the options could work as well.
of note though, 1000 users on Comet without a server such as nginx could be restrictive, as it would require 1 thread per connect. This actually seems to be MUCH less feasible than the AJAX solution for your specific request, unless of course you do have a server able to handle 1000 asynchronous php requests.
Other languages/platforms handle this a little bit better, but it is still one of the major drawbacks of Comet.
all it takes is a username and password
create account
is it really that easy? only one way to find out...
already have an account and just want to login?
login
[–]vduquette 2 points3 points4 points ago
[–]zushiba[
] 1 point2 points3 points ago
[–]nrogers64[S] 0 points1 point2 points ago
[–]zushiba[
] 0 points1 point2 points ago
[–]nrogers64[S] 0 points1 point2 points ago
[–]nemeth88 0 points1 point2 points ago
[–]WDKevin 0 points1 point2 points ago
[–]mikedoesweb 5 points6 points7 points ago
[–]nrogers64[S] 0 points1 point2 points ago
[–]cmwelsh 1 point2 points3 points ago
[–]Kaz3 0 points1 point2 points ago
[–]WDKevin -1 points0 points1 point ago
[–]cheald 2 points3 points4 points ago*
[–]jij 2 points3 points4 points ago
[–]nrogers64[S] 0 points1 point2 points ago
[–]MiHeath 1 point2 points3 points ago
[–]MiHeath 1 point2 points3 points ago