Introducing MemChat: Open source group chat framework in PHP supporting Memcached, APC, SQLite, Flat Files and MySQL

MemChat is an open source group chat framework for personal and enterprise level websites. Written in PHP, MemChat can be configured to run with Memcached, APC, SQLite, Flat files and MySQL as it’s storage engine. With memcached, APC and Flat files serving as temporary storages and MySQL, SQLites being permanent storage engines.

MemChat uses MemBurger API for storing all the incoming messages in the storage engine. MemBurger is an open source PHP wrapper for all the storage engines mentioned above providing Collapsed Forwarding and Stale-While-Revalidate functionality.

MemChat can also be configured to notify the site owners at various event handlers provided. e.g. In case of a wordpress blog, site owner might want to get notified when someone post a new message on one of the blog post. Infact developers can write plugins for custom event handlers. MemChat provides two kind of notification methods. By default, MemChat uses XMPP protocol to notify blog owners. For these kind of notifications, JAXL an open source Jabber XMPP Client Library is used to send instant messages as notifications. MemChat can also be configured to send notifications using SMTP protocol a.k.a EMail.

MemChat also comes with a profanity word filter using PHProfane library i.e. one can configure MemChat to block all spam messages posted in the chat rooms. Developers can write a plugin to add custom spam words in the profanity filter.

MemChat Flow Diagram:
Below is a flow diagram showing how all the above components are clubbed in as MemChat:
MemChat Workflow Diagram

MemChat use cases:
MemChat framework requires a unique alphanumeric id for each group you want to create. For example, WordPress blog makes a good environment to setup MemChat since every blog post have a unique id. Hence to setup MemChat on a wordpress blog all we need to do is, call

$memchat_ui_html = memchat_init($memchat_group_id);

method, where $memchat_group_id = Blog post id.

Similarly MemChat can be setup on a number of places as listed below:

  1. Forums: Since each forum have a unique id per discussion thread, MemChat suits well here. Forum owners can setup MemChat for allowing current viewing users of the thread to chat in real time. If using temporary storage engines (since they scale up well), forum owners can easily write event handlers to save chat messages asynchronously so that interesting discussions can be made a part of actual discussion thread.
  2. Social Networking Websites: A social network will generally have group pages, fan pages, event pages and application pages. Since all pages will have a unique id associated with them, MemChat is a good fit here. Simply pass $blog_id = “group-1234”, for setting up a chat room on group page having id 1234. Similarly for fan, event and application pages.
  3. Blogs: A blog as discussed above is a perfect place for setting up MemChat. WordPress blog owners will be able to setup MemChat on their blog using WP-Chat plugin.

Setting up MemChat in 3 steps:
MemChat can be setup in 3 simple steps:

  1. Download: MemChat is hosted on Google Code.
  2. Update Configuration: Update MemChat config file to setup various default behavior and actions.
  3. Initialize: Include MemChat class file in your PHP template.
    include_once("/path/to/memchat.class.php")

    Next simply initialize MemChat

    $memchat_ui_html = memchat_init($memchat_group_id);

    which will return the user interface HTML code. Finally append it to your template and MemChat group is ready to serve.

The ease of setup can be imagine from the fact that, WP-Chat wordpress plugin development required only the above 3 steps. I was able to develop the plugin within 5 minutes.

MemChat Performance Benchmark
Initial benchmarking results show, On a single apache and single storage instance MemChat is capable of handling over 250 (MySQL) incoming chat messages per second. Capacity reaches in thousands when configured with Memcached or APC cache. Again Memcached configuration and APC no stat feature makes a difference in performance results.

Why still in alpha?
Yes, MemChat is still in alpha release. I want to test all MemChat features on a live traffic and hence I chose my blog for its testing. I have installed MemChat on my blog which is currently using APC cache as storage medium. Over two weeks or so I will configure MemChat with various other storage engines to have a final round of test. Also the event handler and PHProfane plugin feature is still under development. MemBurger API also requires a more modular design pattern so that extending it for any other storage types become trivial.

Try out MemChat on my blog, can be seen as a facebook type chat bar below. This will be soon available as WP-Chat plugin for wordpress blogs. WP-Chat user interface is customizable just like wordpress themes.

Let me know your views and suggestions for improvement.

  • Pingback: Introducing MemChat: Open source group chat framework in PHP … | Open Hacking()

  • Pingback: Wordpress Plugins » Blog Archive » Introducing MemChat: Open source group chat framework in PHP …()

  • Pingback: uberVU - social comments()

  • Rajesh Gupta

    From where can I download memchat. I looked at Google Code but it is not available there for download.

    • Yes as I wrote it is still in alpha and available on my blog for a demo. I wanted to test it on live traffic to be sure nothing is getting screwed. Configuring and tuning can take upto 2-3 weeks depending upon how much the readers are using it 😀

  • Chris

    Hey, that’s exactly what I have been looking for – and finally wanted to create on my own, because I didn’t found it.

    I’d offer you to take part in the development – if interested, please contact me.

    Some points after the first review:
    – Input field not obvious.
    – Links not highlighted.
    – What about user authentication (integration of user database/existing sessions)?
    – What about linking of user names to user profiles?
    – Are multiple Memcached servers possible (selected by group id?)

    By,
    Chris

    • Hi Chris,

      MemChat is also a pluggable chat module with handlers provided for almost every event happening in the background. Hence:

      1. Customing UI is not an issue, infact UI is a separate component all together and you can change the UI theme by a simply change in config file.

      2. You have handler on the incoming chat messages. Write a plugin and hyperlink the fields before saving. Other way, if you don’t want to alter incoming messages while saving, write a plugin on the outgoing chat message chunks. Hyperlink while displaying chat messages.

      3. Again can be handled with plugins. Currently a method is called when a new uses logs in. You can write plugin for that method to authenticate in the background.

      4. Again same as hyperlinking

      5. Yup, multiple memcached clusters are possible. Support will be there for storage engines like mongodb, couchdb and the likes.

      Overall you can visualize MemChat architecture similar to wordpress CMS. Every thing is customizable.

  • Can I user this on any site or just CMS systems? Is there an admin with stats and so?

    • Yes any PHP based CMS will be fine. Basically all MemChat requires as input is a unique id for your chat group to function.

      Admin panel etc all should be added as plugins. Since MemChat framework allows you a handler for all events occurring in a chat group, making an admin panel should be easy 😀

  • Andy

    Plugins? Are they already available or will it be coded sometime?

    • Yeah I will be making available a few plugins to start with. But thereafter you can only reply on open source community.

      Since it will be open source, I assume developers might like to use available handlers for making their own custom plugins. If they wish, they can make them open source too (though not sell, due to license restrictions)

      For instance a very quick example can be, making a website stats module using memchat handler. Since memchat enabled pages sends atleast 1 query on page load, you can use it for stats collection too.

  • Andy

    Hi, do you also have a admin account for testing somewhere?

  • Bob

    It sounds great. I can’t find any code source in Google Code. Something wrong ?

    • Bob, memchat was enabled on my blog since past 1 month or so. I have currently disabled it since I am upgrading it. Expect it in a day or so with real time chat using JAXL library.

  • Hi Guys,

    I have upgraded the wp-chat installation on my blog. You guys might want to check this out.

    Upgraded version is based on Jaxl’s BOSH support and provide real time chat between blog users and blog admins.

  • Andy

    Hi, were is it? Cant see it on any of your sites!

    • Hi Andy,

      I am currently testing the xmpp/jabber version of memchat. My jabber server was giving me problem by aborting sessions with 403 forbidden error. Hence disabled it for non-admins.

      Shall see something coming up by this weekend, i m pretty tied at work 🙁

  • demy

    Abhinav Singh,excellant ,the preformance is also crazy,but i cannot see where to download

    • Looking to release it as a wordpress plugin to start with. Struggling with the tit bit’s of providing an admin panel right now 🙁

  • Bob

    Any news? Is it ready?

  • Hi Bob,

    Yeah I am onto it. Currently working on plugin admin interface part, will post an update soon. Thanks.

  • Christian

    Hi Abhinav, sounds good what you are writing but even if you still develop: why do you not checkin into the google-code svn repository so others can help you or give the project more spirit?

  • Hi Christian,

    Not long before i shall release the same. It’s already deployed at some level in production, will be a hosted solution.

  • Pingback: Introducing WP-Chat :: XMPP Chat plugin for Wordpress | Abhi's Weblog()

  • Memchat is now available as Jaxl IM http://im.jaxl.im. For wordpress users wp-chat plugin does the same work now.

    Here is the wp-chat release blog:
    http://tinyurl.com/2ebqor2

  • Andyleery

    Hi, finally! Waiting for month 🙂
    I just registered and would like to try it out. Is it possible to get a German translation?

    I could do it by myself and I would also provide it to you. Just send me the language file (XML or whatever you guys use). All the best for your projects!

    – Andy

  • Andyleery

    Hi. How come the chat isnt coming up here using Internet Explorer?

    • Hi Andy,

      It’s currently disabled for IE browsers (during alpha stage), while we try to make our backend strong… Beta stage will have all kind of compatibility including for IE6 users…

  • Andyleery

    Oh ok.
    Whats about my first question and when do you think will the beta version come out?

  • Hi Andyleery,

    Beta release is targeted for November end. In beta phase, site approval step will be removed so that chat widget shows up as soon as site ownership is verified.

    FAQ page http://jaxl.im/faq.php will give you some idea as to why site approval step was necessary during the alpha stage.

  • Andy

    Hi, did you change the start of the beta phase again? How long do you think will it still take?

  • Announcing Jaxl v3.x – asynchronous, non-blocking I/O, event based PHP client/server library – http://abhinavsingh.com/blog/2012/07/announcing-jaxl-v3-x-asynchronous-non-blocking-io-event-based-php-clientserver-library/