Choose which way to calculate the PV and UV in Django?
Asked Answered
A

0

1

I'm building a news website using Django and hope this website can handle millions of traffic.Now I'm coding a function that displays 48 hours most viewed articles to readers,so I need calculate the PV.

I have searched for a while and asked some people.I know I have some options:

1.using simply click_num=click_num+1,but I know this is the worst way.

2.A better way is using Celery to code a distributed task,but I don't know how to exactly do it.

3.I heard Redis also can used to calculate PV and UV but,have no idea how to do it and not sure the it can satisfy my needs.

4.Another good way is to use google analysis,but I also have no idea how to do it and not sure the it can satisfy my needs.

5.The last way ,I think the easiest way is to use JavaScript, but I'm not sure whether it can satisfy my needs.

Any friend can give me some advice? Thank you so much!

Afeard answered 10/5, 2018 at 17:20 Comment(5)
You don’t get millions of views from one day to the next. There’s no reason to write something to deal with such traffic before you actually see any scaling issues. Google Analytics can do this for you, just add their javascript to your page. Or create your own little analytics api that you call with a little javascript on your page. Even using a normal database works for millions of views per month.Margiemargin
Thank you so much!Afeard
I missed your tag, did you end up using something?Maxie
Yes, currently,I'm using F() expressions like this, News.objects.filter(id=news_pk).update(pv=F('pv') + 1),in the future I may use something like redis.But now I just want to finish this project as soon as possible.: )Afeard
Hi friend,I asked a new question ,could you help me to check?Thank you so much! #50418700Afeard

© 2022 - 2024 — McMap. All rights reserved.