Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,819 members, 7,806,304 topics. Date: Tuesday, 23 April 2024 at 02:26 PM

Will This Likely Overload My Server Or Crash My Database? - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Will This Likely Overload My Server Or Crash My Database? (1385 Views)

How To Insert Excel Data Into My Database / How Can I Setup My Server To Start Selling Bulk Sms / How Can I Link A Form In My Website To A Table In My Database (2) (3) (4)

(1) (Reply) (Go Down)

Will This Likely Overload My Server Or Crash My Database? by Nipeks(m): 5:58am On Oct 22, 2013
I am currently building a website that has both forum and social networking features including chat platform. Since I'm going to need to know when every user is online or offline, I used ajax to create an xmlhttprequest/activexobject that updates a datetime cell named 'online' on my mysql table with php. Now, this script runs every 1000 milliseconds so any online cell that is not updated within 5 seconds is tagged offline. It runs fine on my PC but since I haven't hosted any site online before, I'm not sure if it will overload my server when my users start increasing in number. So, the question is - will this overload my server or crash my database? If so, what are the adjustments I can make or is there a better option?
Re: Will This Likely Overload My Server Or Crash My Database? by Nobody: 6:56am On Oct 22, 2013
5 seconds is too small o my guy, then if your server is not powerful enough, it shall surely die
Re: Will This Likely Overload My Server Or Crash My Database? by spikesC(m): 11:29am On Oct 22, 2013
You need to research on node.js, server poling is an old technology wink
Re: Will This Likely Overload My Server Or Crash My Database? by EasyNaijacom: 8:56am On Oct 24, 2013
Wtf is 5 seconds? So if a user goes into the forum to read a post, he'll be tagged offline before he even starts reading the post? smh
Re: Will This Likely Overload My Server Or Crash My Database? by Nobody: 9:35pm On Oct 24, 2013
Or if the user pauses to pick a phone call? or to ping his babe! Or if you type as much as this and you want to push submit button.
Re: Will This Likely Overload My Server Or Crash My Database? by DualCore1: 12:33am On Oct 25, 2013
You will end up with 'maximum mysql connections' kinda errors sooner or later.



*dhtml:
Or if the user pauses to pick a phone call? or to ping his babe! Or if you type as much as this and you want to push submit button.
Quire unrelated this is but I hope I can still say it. There's a girl who dropped her pin in tht BBM pin thread. Saw her message and my instincts thought of you next, dunno why. You shld check her out smiley
Re: Will This Likely Overload My Server Or Crash My Database? by Nobody: 6:12am On Oct 25, 2013
Wheeeere is the girl? i should ave been monitoring that thread, brb
Re: Will This Likely Overload My Server Or Crash My Database? by Nipeks(m): 5:08am On Oct 29, 2013
@all I used AJAX. Even if you are away the script keeps pinging the server every second (1000 milliseconds) in background as long as the webpage is open.@Spike C How does the 'nodejs' work?
Re: Will This Likely Overload My Server Or Crash My Database? by sisqology(m): 5:43am On Oct 29, 2013
*dhtml:
Wheeeere is the girl? i should ave been monitoring that thread, brb



Ashewo ma ni bobo yi ke!!! Married man
Re: Will This Likely Overload My Server Or Crash My Database? by sarutobi: 5:33pm On Oct 29, 2013
As others have pointed out, Polling at intervals will cripple your servers especially if u use apache. And most of the time you connect to the server even when there is no data to fetch wasting bandwidth and increasing network traffic.

now, you have 2 options:
1. using nodejs with socket i.o
2. using only nginx with long polling.

1. Using nodejs with socket i.o:
(please note that i will not go in details as i feel these information is available evrerywhere online. I am just pointing u in the direction that solved my problem sometime ago.)

Nodejs handles all requests to it from one thread. It is event based which means while it is doing heavy work, it can use available resources to do other works. In Short, it is asynchronous in nature. Anyways, this means it can handle 10s of thousands of connections maybe 100s of thousands if optimised. When combined with socket io, u do not need to poll anymore as the connection will be opened only once from the browser and it is kept open. Whenever there is an update on the server, you could use a pub/sub technique to subsribe to updates for a user and then push it directly to that user's browser(as in the case of chat messages). At intervals, the user's browser can send a heartbeat to nodejs to say "i am still online". It reuses open connection so no hassle.

If i will go this way, i will have to dump mysql for this task ONLY, and use something in-memory like redis.

2. using nginx with longpolling:
The interesting thing is that this technique is still being used by facebook. open facebook in chrome browesr, then ctl-u, click on network. U will find out that facebook makes an ajax request to thier server at an interval . But the difference here is that, the response does not come back immediately. Facebook will not send a response if there is no information for the current user. It keeps the connection opened until it times out on its own. They anoda one is made immediately. This means facebook keeps an activity-like table for all its users that gets updated whenever an action has been taken which relates to a user. This table is then polled(maybe) or like before with a pub/sub and updates is sent back with the open connection.

Also with this technique, i dont see how mysql will last.

In conclusion, since u are just starting out, play with a few tricks to see how they behave. u should not have any problems for now until ur app starts to get real popular.


Sorry before i forget: since nginx will be using PHP, I suggest you have multiple instance of php runnnig in fast cgi mode, and then feed them to nginx as a pool. Nginx times out with 502 gateway nonsense if it has no php instances left to run requests.
Re: Will This Likely Overload My Server Or Crash My Database? by kingsley2rhyme(m): 2:45pm On Oct 31, 2013
Mehn!!! See I.t gurus, I'm so happy to visit this thread, I just developed an interest in I.T after I went for a training on oracle 11g, now iv just learnt how to develop a website on joomla and am hungry for more.
All of this ajax and d rest sounds so foreign to me. Pls, anyone staying close to Ibafo or Berger shld pls help out on this. Thanks house.
Re: Will This Likely Overload My Server Or Crash My Database? by Nobody: 6:15pm On Oct 31, 2013
sisqology:



Ashewo ma ni bobo yi ke!!! Married man
The babe escaped with my moni!

(1) (Reply)

How To Check Original Tecno Android Phones / How Do I Get Ftp On Localhost / Unlimited Google Drive Space FOR LIFETIME

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 51
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.