From c337280e477226eacb0f5c8123a0fd495d307f43 Mon Sep 17 00:00:00 2001 From: Neil Williams Date: Mon, 27 Aug 2012 21:53:37 -0700 Subject: [PATCH] fastlane: Separate votes on some links and their comments. If a specific link has ridiculous traffic, we can inform the apps (via ZK live config) that votes on it should be sent to a separate, dedicated, queue to avoid overwhelming the rest of the system. --- r2/example.ini | 2 ++ r2/r2/lib/app_globals.py | 1 + r2/r2/lib/db/queries.py | 12 ++++++++++-- r2/r2/lib/queues.py | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/r2/example.ini b/r2/example.ini index 6aafe5de4..0d298ab7c 100644 --- a/r2/example.ini +++ b/r2/example.ini @@ -496,6 +496,8 @@ beaker.session_secret = somesecret [live_config] # make frontpage 100% dart frontpage_dart = false +# links that get their own infrastructure (comma-delimited list of id36s) +fastlane_links = # spotlight links for subreddit discovery sr_discovery_links = # probability of the subreddit suggester showing up in the spotlight box diff --git a/r2/r2/lib/app_globals.py b/r2/r2/lib/app_globals.py index 0c2d891fc..d31ea4f3e 100755 --- a/r2/r2/lib/app_globals.py +++ b/r2/r2/lib/app_globals.py @@ -186,6 +186,7 @@ class Globals(object): ], ConfigValue.tuple: [ 'sr_discovery_links', + 'fastlane_links', ], } diff --git a/r2/r2/lib/db/queries.py b/r2/r2/lib/db/queries.py index 53091c7ee..7e6020189 100755 --- a/r2/r2/lib/db/queries.py +++ b/r2/r2/lib/db/queries.py @@ -1284,6 +1284,7 @@ def run_commentstree(qname="commentstree_q", limit=100): vote_link_q = 'vote_link_q' vote_comment_q = 'vote_comment_q' +vote_fastlane_q = 'vote_fastlane_q' def queue_vote(user, thing, dir, ip, organic = False, cheater = False, store = True): @@ -1294,9 +1295,16 @@ def queue_vote(user, thing, dir, ip, organic = False, if store: if g.amqp_host: if isinstance(thing, Link): - qname = vote_link_q + if thing._id36 in g.live_config["fastlane_links"]: + qname = vote_fastlane_q + else: + qname = vote_link_q + elif isinstance(thing, Comment): - qname = vote_comment_q + if utils.to36(thing.link_id) in g.live_config["fastlane_links"]: + qname = vote_fastlane_q + else: + qname = vote_comment_q else: log.warning("%s tried to vote on %r. that's not a link or comment!", user, thing) diff --git a/r2/r2/lib/queues.py b/r2/r2/lib/queues.py index 3eadb0b50..bf04126ec 100644 --- a/r2/r2/lib/queues.py +++ b/r2/r2/lib/queues.py @@ -73,6 +73,7 @@ class RedditQueueMap(QueueMap): self._q('register_vote_q', self_refer=True) self._q('vote_link_q', self_refer=True) self._q('vote_comment_q', self_refer=True) + self._q('vote_fastlane_q', self_refer=True) self._q('log_q', self_refer=True) self._q('usage_q', self_refer=True, durable=False)