How does Tinder know who's been seen? (Backend)

我们两清 提交于 2019-12-13 04:27:56

问题


I have a dynamodb source of models. Now I query them via ElasticSearch, so I can make a geo search.

give me all models in 30 km circle.

Now the user has a Tinder system. So can wipe. How do I know which models I don't have to retrieve anymore? What is the best way to do this?

A table with already seen maps? Then I subtract from ElasticSearch, get an array with 100 cards and compare them? If he has already seen all 100, then ask ElasticSearch again? That makes little sense. The more the user has seen, the longer the requests go. How do you do that?


回答1:


This is an opinion based question hence my opinion based answer.

One way to do this is Pre-warm what has to be shown to user.

Solution:

A background job runs every x hours which fetches all the possible results from Elastic Search using search query with given parameters like age, gender, interest, location etc. The information about what user has already seen can be stored in a bloom filter. All the records that are not already seen, can be stored in cache and when user fetches next record cached entity is returned. Whenever user sees one person, that person is added to the bloom filter so that, same person is not shown again.

However this is very static approach and will require some extra thinking around

  1. Incorporating super star functionality

    whenever A marks B as super like, irrespective of everything A is add to B's to be shown list.

  2. Whenever the batch job will run if elastic search is queried, most probably first few results will be same as previous one

    This is a tricky problem to solve, we can add some sort of randomisation or parameter(like last updated, or keep a pointer of how many users we had already traversed in the last job and this time start from +1 of that counter.) which can make sure that whenever we query elastic search results are almost random and first few are not always the same.

  3. Batch job can be triggered when required.

    Let's say user changes his preference/location, we should be able to invalidate the cache and rewarm the cache with fresh results.



来源:https://stackoverflow.com/questions/56260727/how-does-tinder-know-whos-been-seen-backend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!