Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wp v2 rest request from Android App overload CPU usage

I have created Android App for news website (wordpress), i used WP v2 API to get posts from database, the problem that even less than 10 users that using the App in same time can overload the server (CPU usage).

When user open the App i send get request (using retrofit2) and get the first page (json array with 10 objects of that represent posts).

/wp-json/wp/v2/posts?page=1

Then for every post i send another request for media to get image.

/wp-json/wp/v2/media/21342

Without the App the server overloads when 600-700 users browse the website, with the App it overloads at 300 users and 10 App users.

Why it happen what is the difference between wp-v2 request and browser website loading?

like image 778
Pavel Poley Avatar asked Nov 25 '25 17:11

Pavel Poley


2 Answers

Try to reduce the number of requests by passing down the image URL with the inital request. I have done this using this embedded parameter:

https://developer.wordpress.org/rest-api/using-the-rest-api/linking-and-embedding/

Additionally, maybe try using something like S3 Offload Media plugin to serve your images off of a different server than your application server.

Pantheon has a whole site dedicated to WP at Scale: https://scalewp.io

like image 120
plushyObject Avatar answered Nov 28 '25 06:11

plushyObject


Don't load the detail unless the user taps it to reduce strain on the wordpress server. The browser is loading as needed is why the increase on CPU. Your app appears to be loading in advance for items that may never be viewed.

like image 33
danny117 Avatar answered Nov 28 '25 07:11

danny117



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!