mercredi 27 juillet 2016

What/How can I optimize for my news feed API?

This is more of an architectural question.

I am designing an API (lets call it API 1) for a mobile app that will query my API for new articles. I will call another API (lets call it API 2) that returns Raw news feed to me.

You ask why is API 1 needed at all? Well, it will do lot of optimization like curate edition specific news, format it in such a way that it is easier and light for the mobile to assimilate the feed.

So API 2 return 1000+ feeds to me and then based on my curation lets say I have 500 feeds to send using API 1. Now with caching and all it is all good for my backend. The problem is with the mobile devices (especially older ones). They start breaking a sweat with huge responses (270kb after Gzip).

My solution: Pagination:

I can split the 500 news articles to 5*100 articles. The app can request for page 1,2,3,4 and 5. Potential cons: When API 1 sends fresh articles the split of 5*100 is disturbed. For instance see the news feed on mobile device:

Article 1,

Article 2,

..

Article 99,

Article 100

----Page ended----

Article 101,

Article 102,

Now after API 1 refreshes feed:

New Article 1,

New Article 2,

Article 1,

Article 2,

..

----Page ended----

Article 99 (duplicate),

Article 100 (duplicate)

Article 101,

Article 102,

What are the best practices for such a problem?

Aucun commentaire:

Enregistrer un commentaire