java - How to optimize the interface to return large amounts of data?
世界只因有你
世界只因有你 2017-05-17 10:00:33
0
4
920

Description of Requirement:

The peripheral platform calls the interface to query the user's song list recommendation information based on the mobile phone number. Each user will have about a thousand pieces of recommendation information. Each piece of recommendation information includes, Song ID, song name, copyright ID, Audition address field .

I need to query multiple tables. Each query takes about 4 seconds. After the query is completed, the data needs to be assembled before returning to the interface.

The return format is json. In this case, the interface return will be slower.

I thought about putting the data in the redis cluster in advance, but later rejected it because the number of users is about 5 million, and the size of recommended information for each user is about 200kb. Storing redis will consume a lot of memory, so I rejected it. But I can’t think of any other good solutions. Could you please help me find out if there are any good suggestions for how to deal with such a demand? grateful!

世界只因有你
世界只因有你

reply all(4)
我想大声告诉你

The bottleneck is that it takes 4 seconds to query many tables. Is there any point in the logic that can be optimized? If not, then these 4 seconds must be spent. With other data transmission formats, the network communication time cannot be less than 4 seconds no matter how optimized it is.
Either the client sends a recommendation request without a user being aware of it, or the query logic is optimized.

洪涛

For linked list query, post your sql. Why not query separately? I guess you spend a lot of time in SQ

给我你的怀抱

1. Return a thousand items at a time? Would it be faster to do 50 items at a time? What about multiple paging requests?
2. I feel that it is inappropriate to directly deny the caching solution. Not all users with more than 500 W are active users. Is redis acceptable for estimating the number of active users?
3

某草草

Add the ID attribute to [Recommended Information] and save it in redis. This amount should not be large.

The information recommended by each user is also stored in redis, but only 1,000 IDs of [recommended information] are saved.

In this case, each user’s recommended information will not be 200kb.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!