php chat concept

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
E_Fox
Forum Newbie
Posts: 9
Joined: Sun Jan 12, 2003 11:33 pm

php chat concept

Post by E_Fox »

How does php chats work? Do they keep open a live connection or it just looks that way?
DeGauss
Forum Contributor
Posts: 105
Joined: Tue Oct 22, 2002 9:44 am
Location: Gainesville, FL

Post by DeGauss »

Are you talking about the IRC Module stuff built for PHP?
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

PHP cant really have a proper relay as it cant print onto the page in real time, it must be refreshed before new data is added.
E_Fox
Forum Newbie
Posts: 9
Joined: Sun Jan 12, 2003 11:33 pm

Post by E_Fox »

I don't know about the irc module for php. where can I find it? I just a saw site which had php chat, and I'm wondering whats the concept, because browser don't keep the connection alive. As soon as the page is loaded the connection is closed.

Second, it must be all server side processing and that means too much load on the server.

thanks for the replies
DeGauss
Forum Contributor
Posts: 105
Joined: Tue Oct 22, 2002 9:44 am
Location: Gainesville, FL

Post by DeGauss »

Oh... I understand now.

I'm working on (ha!) something along the lines of what you're talking about.

I'll be quite happy to release the source code to you if you want to develop it further, as i'm notorious for developing things to a certain point and then losing interest...

http://www.vanillacity.com/geek/phptalker/
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

In PHP chat scripts the database connection is never closed, refreshing the browser mearly gathers the new information entered into the database. And yes, php chat scripts do place a high load on the servers performance, think about it, 30 people chatting = 30 database queries every 3 seconds (refresh rate) + bandwidth consumption.
User avatar
Skittlewidth
Forum Contributor
Posts: 389
Joined: Wed Nov 06, 2002 9:18 am
Location: Kent, UK

server load

Post by Skittlewidth »

I've very recently written a chat script which is only for use between 2 or 3 people, and I've deliberately slowed the refresh rate down to once every 30 seconds for two reasons - one because when I'm chatting I should probably be working and so should the other person, and two I'm concerned about the load on the server. 8O
I reckon the database gets queried up to once every 5 seconds if a particluarly good discussion is going and once every 15 to 20 seconds if the message pane is left open (you can temporarily close it when you aren't paying attention to avoid needlessly refreshing and calling the database).
My question is, just how much of a load will this create on the server? Normally I wouldn't be too concerned, but its hosted (I bought space) on the company that I work for 's commercial server, and the last thing I want is for my boss to pick out my IP address from the log files! Would a drop in server perfomance be noticable or even caused by just two people running this script between 9am and 4pm?! :oops:

Skittlewidth
fractalvibes
Forum Contributor
Posts: 335
Joined: Thu Sep 26, 2002 6:14 pm
Location: Waco, Texas

Post by fractalvibes »

Here is a link to an ASP-based chatroom application:

http://www.aspalliance.com/peterbrunone/chatroom.asp

If PHP has the equivalent of Application variables, it could be adapted.
Application vars can be shared by all sessions using an application. If PHP has no equivalent, you could use a DB instead.

Phil J.
Post Reply