Posted 23 January 2013 - 07:13 PM
I own a chat on my server. Sometimes when there are a lot of peaple, my whole website become slow and make user leave
So, my provider (i have a linux server) talk to me about PHP APC, that will be a good idea to increase the performance with caching
I search on the web, but i still have some question!
What should i cache with APC? Query string, vars......
Not that my query string are 95% dynamic....? It's that good for that...?
For my chat, i use short polling(ajax/json query send every 2 or 3 seconde)... but now i switch to long polling in a while loop. My long polling isn't yet online, it's on my dev server!
Thank for giving to me where should i start with APC!
Thanks a lot
Posted 23 January 2013 - 07:24 PM
Turn on APC and see if that improves performance enough. If not then you can revisit the issue of caching.
Posted 23 January 2013 - 07:39 PM
The admin of my server told me that apc is already installed!!!
I can start using it now!!!
So any hint for me?
Posted 23 January 2013 - 08:38 PM
But if you already have it installed then the file caching alone isn't enough. What does your code look like? You can probably store some information in APC to spare the database some queries.
Posted 24 January 2013 - 03:43 PM
For now i have my script php and my script JS and Ajax. So depending on the action made by the user, ajax call my php page and return the good thing. As i say, i use long polling, so a while loop on the server who check for new message to show on the chat. so when i find a new message, the while loop stop and return the new message(s) to the chat and show it.
I want to speed thing because when there are a lot of user, the chat makes whole site slow....
But with APC, i don't know what cache in it? do i should cache dynamic query, uservariable.....other...
that why a asked some help!
Posted 24 January 2013 - 05:15 PM
There are a myriad of concerns when creating an AJAX-based chat system, especially when you start to get a lot of users. Most of which requires intimate knowledge about the way all systems involved function, potential bottlenecks, optimization tweaks, and (most importantly) being able to properly profile your code.
I've made an AJAX-based chat system which supported a few hundred users. I had to tweak everything including the PHP session handler (or rather circumvent it completely, to maintain the responsiveness and keep the system resource utilization to a minimum.
You should perhaps also consider hiring someone who knows what they're doing, if this is a project which is either commercial (in other words, making you money), or if don't have a few weeks to get to grips with everything.
As for how to use and configure APC, I recommend reading the PHP manual page. Though, as Requinix already pointed out, you shouldn't have to do anything to use it.
When it comes to what it caches... That's a whole different question, and one which would take a lot of time to explain properly. Thus I recommend a search for "opcode cache" on Wikipedia, or similar, and read about how they work in general. After you've done that, the PHP manual should give you the necessary details for that particular implementation.
Edited by Christian F., 24 January 2013 - 05:19 PM.
Posted 28 January 2013 - 02:25 PM
This chat use a bit vars sessions only to check if a private msg need to be shown or not. because on my chat, we can send private msg. so i check if the receipient is the current member, if yes i show the private msg.
I tried a bit to work with APC last friday. I've made a simple test. Look:
$bar = 'BAR'; apc_store('foo', $bar); echo apc_fetch('foo');
At first, it work very well BUt, if a make some refresh page... 50% of the times it show notting(empty vars)... and 50% show "BAR"
if i did apc_exists... some it exist and sometimes not!
So i asked why to the admin of my server (i'm on a VPS server).
It is short answer was:
APC use shared memory between same process of same tree... so you have to fetch to see if your apc vars is empty or not.......
man... he told me only that!!
So i'm totally lost! is that normal that sometime it fetch an empty string and sometime not.....
Thanks for your help!
Posted 30 January 2013 - 01:45 PM
Edited by pascal_22, 30 January 2013 - 01:45 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users