Is there a reason that chat has a slightly large delay.

Is there a reason that chat has a slightly large delay. Is there a way to optimize the options so it’s instant.

  • Jack Kitterhing
    • Code Norris

    Hi there @ken

    I hope you are well today and thank you for your question, there shouldn’t be a large delay, but there may be a slight delay as the message is posted, though it shouldn’t really be over noticeable, what sort of hosting do you have?

    What is your PHP memory limit? How many plugins do you have installed? Can I have a link to chat on your site?

    Thank you!

    Kind Regards

    Jack.

  • Paul
    • The Green Incsub

    @ken,

    A couple of thoughts. First there is no ‘instant’. Realize when you post a message it is sent to your server and inserted into the database. Then other participants are also polling the server for new message. So there will be some delay as you are not sending message directly to each user. What sort of delays are you seeing? 1 second, 5 seconds?

    In wp-admin go to Chat > Settings Common. On the first tab ‘Poll Intervals’ check the top settings for ‘How often to update message lists’. This controls how often the chat plugin polls via AJAX your database for new messages.

    Next, on the same settings panel check the bottom option ‘Chat Session Polling Content’. Make sure this is set to ‘Plugin AJAX’ and not ‘WordPress AJAX’. The difference is sometimes many milliseconds. Using the ‘WordPress AJAX’ the chat plugin will route AJAX request through the default WordPress AJAX channel. This is slower because even for AJAX request WordPress goes through the startup process and loads all plugins and environment just like a normal page load. When using the ‘Plugin AJAX’ the chat AJAX request is routed to the chat plugin’s own AJAX handler. In that scenario the whole of the WordPress plugins and environment are not loaded. Just what is needed to process the chat request. So will be much more efficient.

    As for memory yes increasing your PHP memory will help. But still WordPress only allocates enough memory to use. See the section of the Codex about memory http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP WordPress will by default only allocate 40M for for regular and 64M for Multisite. So make sure also increase the memory limit there.

    As for your server sounds quite capable. But well my experience with hosted dedicated servers is they are handed out to you untuned. Most hosting companies rely on you knowing how to for example tune MySQL memory and optimize things. I’m not saying your is not. Just my past experience.

    Lastly, is there a way we can see a chat session to judge how the timing is working?

  • Paul
    • The Green Incsub

    also, just checking from your home page I see the chat AJAX requests via my JS debug console. See image.

    Overall these round trips times are very low. Looks like the average time for the first 5 AJAX requests is 240ms which is pretty good. But note these are for just requests for new chat sessions. Not for actual posting of a new message from a current chat session.

    Could be there is something with the MySQL setup where INSERTS take longer.

    Let us know. Keep us posted.

  • Ken
    • WPMU DEV Initiate

    It feels like I was able to optimize the chat by setting the PHP limit to 512 and set the poll rate to 0.5. Your simple solution did the trick. Although it is still a little delayed then I would like it’s more then good enough to live with. Thanks.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.