문제

I am using Amazon S3 for storing images and YII CListView is used to list each page item. Inside partial view that represents each item of CListView, there are 2 calls to Amazon S3 api , once for checking if file exists and second to actually fetch image and show.

Since page size is 20 , and average latency is 200ms per image and therefore for 20 images, total of 20 * 200ms * ( 2 requests per item ) = 8 seconds are taken

Since in javascript , I hide the view till all page elements are loaded, so it keeps on loading for 8 to 10 seconds when page size is 20 and it is quite slow..

Do we have some YII extension that has solved this problem with CListView and S3 download integration which does it faster ?

도움이 되었습니까?

해결책

Considering that when you cold launch your app, you don't know nothing about your images, the images might or not exists on S3, I don't see much options you can take here, just one: cache.

Having cached the retrieved items would make the difference. Memcache would suit if your item size is not bigger than 1M.

On the other hand, I would reduce drastically the calls to S3 (as they cost), maybe keep locally a flag to know if the image exists on S3 or not. And would directly link to CDN rather than fetch it.

You can even preload the next pages, based on where the user is. You can use a Message Queue as Beanstalkd to manage background jobs.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top