Instant messenger

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
jasonmc
Forum Newbie
Posts: 7
Joined: Wed Oct 06, 2010 5:02 am

Instant messenger

Post by jasonmc »

Hi I am about to start creating an instant messenger for a project (from scratch) and I am kind of stuck as where to actually start with it. I have created various websites with PHP and I love PHP programming so I really want the majority of it to be PHP/MYSQL. I was wondering if anybody knows of any good tutorials on this type of thing with a walk through of the code? Many thanks in advance for any replies.
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

Re: Instant messenger

Post by Bind »

http://phpclasses.org/ has a few classes dealing with private messaging systems.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Instant messenger

Post by requinix »

Are you writing some new IM system or just something to interact with existing ones?
jasonmc
Forum Newbie
Posts: 7
Joined: Wed Oct 06, 2010 5:02 am

Re: Instant messenger

Post by jasonmc »

Thanks for the link Bind :)
Hi Tasairis, i'm hoping to build my own peer to peer IM from scratch...i've been searching the net for the last 4 days almost non-stop for a good tutorial but can't find a very good PHP one. Thanks for the reply.
User avatar
twinedev
Forum Regular
Posts: 984
Joined: Tue Sep 28, 2010 11:41 am
Location: Columbus, Ohio

Re: Instant messenger

Post by twinedev »

If you are talking about doing a IM system that is through a web interface, doing a basic refresh to look for new messages, here are some things to keep in mind that a lot of people when first trying this may not realize or overlook.

Say you tell it you have a frame for the message, and to once a second to refresh the latest message, and say you have 10 people on it, and each persons data is listed in an "online" section (including their picture)
So that page call, and every item being used on the frame (Style sheet files, javascript, images) send a request to the server (10 per second each). (the browser may cache them, but it still sends a request back to the web server to see if needs a new copy or to use the cached copy).

All of these also create a separate entry in the log files, so you have 1 page, and 10 images (one per user, not to mention any emoticons) and 1 style sheet, that means there are 120 entries added to you access-log file per second! 72,000 entries for just 10 minutes of chat!

Database look-ups... You should be checking to make sure they are logged in each call, load up possible permissions, load up the records for the current chat conversation, load up their user info etc, each of these db calls get called 10 times a second. If possible check with your provider to see if you can create a table for the database using the MEMORY engine (instead of InnoDB or MyISAM). Then keep the current running chat log and a copy of current online people (the basics, id, displayname, image) in a memory table.

Try to eliminate as much as possible that gets requested and then sent back out. (ie, if you can set the server to tell the browser that images/css/js are good for a certain number of days, and that it doesn't even need to check with the server again until that time is up).

Not saying it can't be done, just some things to keep in mind. If you get a lot of use, the resource use can get real "fun" to optimize.

-Greg
Bind
Forum Contributor
Posts: 102
Joined: Wed Feb 03, 2010 1:22 am

Re: Instant messenger

Post by Bind »

IM Private/Instant Messaging Systems are not constantly refreshing http request real time active chat systems.

2 completely different animals.

The resource consumption on Private/Instant messaging systems is very low.

After all they are simply text saved and pulled from a database when the user clicks the "message waiting" link ... not an "active" real time chat.
Post Reply