Major performance issue with admin-ajax.php

Hello Themeco,
We have dedicated resources and quite a powerful hosting for mere WordPress sites and it goes down when CornerStone is used for text fields.

CornerStone triggers admin-ajax.php for each character typed or removed. Copy pasting content is fine, but manually typing it blows up the server.

Hopefully you can zoom in:

In the second screenshot, we deleted a few words and many of admin-ajax.php calls were sent. If we have 8 users typing text at the same time in different pages, the server fails with a 503 error.

Can we do anything to add a JavaScript timeout? So that every character typed or removed resets the timer after which it triggers the call only once to admin-ajax.php after the user stopped typing for 1 second?

Something similar to this would work:

// Setup before functions
var typingTimer;                // Timer identifier
var doneTypingInterval = 5000;  // Time in ms, 5 seconds for example
var $input = $('#myInput');

// On keyup, start the countdown
$input.on('keyup', function () {
  clearTimeout(typingTimer);
  typingTimer = setTimeout(doneTyping, doneTypingInterval);
});

// On keydown, clear the countdown 
$input.on('keydown', function () {
  clearTimeout(typingTimer);
});

// User is "finished typing," do something
function doneTyping () {
  // Do something
}

Thank you for your help!

Hey @magikweb,

This might not be related to server resources but server settings. A setting or combination of settings might be causing this. In my test site, admin-ajax was triggered 30 seconds after typing.

I tried modifying it using the Heartbeat Control plugin and it triggered after 60 seconds after I’ve modified the frequency to 90. You can try it to see if it helps. Just note though that this is my personal test and observation and I don’t guarantee that this will fix the issue on your end.

I will need to post this in our issue tracker so we could get feedback from our development team if there’s something that could be done about this. Please note that we could not give an ETA though. Please stay tuned for updates.

Thanks.

1 Like

Hello @christian_y,
Thank you for the follow-up!

I enabled the plugin and the problem persists.

If it gives you any hint, here is the form data sent (without headers) after every character we type.

_cs_nonce: e18620b284 action: cs_controllers request: H4sIAAAAAAAAA41SS47bMAy9iqBuk4EdO5nYy34W3XVfBAYjUbEKWTIk2Zg0yIHmHHOxkvZkZlutRPLxkY/kTYLKNvgk29836WFA2cqIXmNsW3Q4oM9fIau+bQu5kSNEGAh7kyr4jC+Zv0PQnLV4fCaUhgwcGEPKndUUq+X9vpFnJuJA3ZTHPex1sUNjYF+XlTpUdVnUzfOzKZqKMQ+SHkFbfyGS72+vA8SIf8XkxRjDH+RiA6YEF27gV5iimEMSPkwzwvTyDkoCvZhtjhgtbsSMnigIkwQJ5a4pIFKwWYzM4JD8w+hALeqFRpF7jAMRh+mdkp3x7dWHGXh6bM6BeIQOk+rxSfx0awWDEQRx2WTjimInWILSLBcevyQmmIONT+sjWecp5+C7dcbyh5/DdRFOJXAA2s8nxpIGwhgHF3IqG5WjcRhwCTeyj2go+IV10qrl6umyzQySHzbEC43zkZWv47JS0o+RMMsSmdxBovVL6oCslK8PkgfftzBeRTDUqEZjPWqKdQ82TraqVeBcmLiVLuLFLs1/Hs96MKUxhxp1sW12UG7rqlRbuhm1LRWezdHUh1rtFuoIPlnO5JvsrdO0U7rl0+bD6lSYOF7wCWbqvtxXzbGsjsei2RWsjY///yqe7vRO93+EBgHvNgMAAA== gzip: true

Also, it’s a WPMU. If there is anything we can do to help you reproduce the problem and hopefully help us find a solution, let us know! We can give private access to files and/or WP if needed (backups are created systematically).

Thanks for the update. I’ve posted this in our issue tracker and we’re waiting for feedback regarding this issue. If you can provide WordPress Admin and FTP access to a staging copy of your site and keep it on, that would be best. Just note though that we can’t provide an timeline as to when we can get a feedback from our development team.

Hello Christian,
I will attach a secure note to this reply so you can reproduce the problem.

Hi @magikweb,

This is added to our issue tracker for further testing. And thanks for providing the credentials. Yes, each typed key issues ajax request, and for now, please do the editing in separate text editor (notepad) and copy and paste the content to the builder.

Thanks!

Hello @Rad,
Thank you for the follow-up. Let us know if there is a temporary JS fix we can apply (we’re comfortable editing files). It’s not an emergency, but we don’t have control over what our clients do with their websites. :slight_smile:

Thank you for the great page builder!

Hi @magikweb,

Regretfully, there isn’t a way to fix this with custom code. Text inputs need to be able to process shortcodes and apply the same PHP formatting functions that are used on the front end. Otherwise it wouldn’t look exactly like it does when you view the site live. It’s not quite every keystroke as it will ignore a keystroke if a new one comes in fast enough (using the most up to date info) but it’s certainly enough to fire a large amount of render requests.

A big contributing factor here is that you’re using multisite. On single installations we communicate using a custom AJAX endpoint. On multisite all the calls go through admin-ajax.php - this means all the plugins you have that initialize things for WP admin run their code. It adds up fast.

We have some notes on improving this process specifically for multisite, but at this time I can’t provide an ETA on when that will be available.

Hey,

I am having the same issue. Is there a temporary fix for non-multiwebsites? I have to design a lot at the moment and already did it with the copy-paste from editor. But that is really annoying. Is there a php hook where I can make temporary changes? Or can you provide fixes from the JS file? I need this to work quite soon…

Hey Mike,

I have posted your case in our issue tracker. Please stay tuned.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.