-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #104: Manage, throttle comments with Redis #131
Conversation
4f8d633
to
91a3bc4
Compare
filename: file.filename, | ||
line: line, | ||
comment: comment | ||
}).save(function(error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.save(logger.error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error
parameter is usually null, so we need to check it before logging it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
facepalms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't facepalm. 😄
I did exactly the same thing last night and was confused for way too long about why I was seeing "null" in the log.
Is there any type of test we can add here? Seems like a good candidate for one. |
Good question. We could definitely test that items are successfully added to the Redis queue. I would also love to test whether all comments are accepted by GitHub. That would take a lot of work (and testing infrastructure). I would love to help add that but wouldn't want to block on that in the meantime. |
Does someone really need to use a credit card to test the redis feature? Couldn't we share a dev-hobby |
Good question. I would love to help find a way to test the feature with entering a credit card. Unfortunately the
—https://devcenter.heroku.com/articles/heroku-redis#create-a-new-instance Thankfully the credit card is only needed to verify identity. If I understand correctly, there should be no charges.
—https://devcenter.heroku.com/articles/account-verification#verification-requirement |
Another challenge with using a shared Redis instance is that another worker might process the queue before the worker being tested. |
It's a good point. Unfortunately it looks like entering a credit card for verification is going to be the easiest solution. If it's not Redis, there's going to be free add-ons in the future that will require it. |
var kue = require('kue'); | ||
var url = require('url'); | ||
|
||
var config = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about this? https://gist.github.com/darkwing/929bc313c69ac307d49c
2b7926e
to
6d3d270
Compare
How many seconds are we waiting on each comment? |
It depends on the |
Is there a way to make it wait longer after several comments? GitHub started blocking after about 20 comments in a row during my tests, and adding a 2-second delay after about 20 comments prevented the spam-protection from triggering at all. I believe hitting the spam protection multiple times in a row can cause a temporary ban, but I haven't seen anything that suggest how long the ban lasts, or how many times we can hit the spam-protect before the ban. |
Good question. I noticed that, too. It looks like submitting lots of comments in quick succession will trigger temporary spam protection, at which point all future comments will be rejected for around 30-60 seconds. If there's a delay between comments, the spam protection system appears not to be triggered at all. In my testing, waiting for 250 milleseconds between comments is enough for all of the comments to go through successfully. If a comment does fail, the wait between re-attempts will increase, first to 500 milleseconds, then to 1 second, then 2, then 4, etc. |
6d3d270
to
cff3a76
Compare
Hey, nice job figuring out that GitHub sends back a |
f75b2cb
to
bdc279a
Compare
bdc279a
to
9c98eb2
Compare
So I've been thinking about tests. I love writing tests, and love having tests, but to be honest I'm having a hard time thinking of a test that would be valuable here. Our tests already cover the Redis queueing/processing logic, so those results are definitely still valuable. We could additionally test that the queue itself works as expected, but Kue already covers that. The real test is whether GitHub accepts all of the comments Discord sends, but we don't have a way of automating tests like that at the moment. I would love to help us build that testing infrastructure down the road, but would prefer not to block on it right now. |
I doubt there is a good way to test that, but we probably should monitor the success vs reject rate. Is there a way to do that with new relic? |
Would redis be good storage for the success/reject rate? |
If we can get persistent storage on it, I can't see why not. |
Hm. I'm not sure I understand. Do you mean using Redis to log how often comments are rejected as compared to being accepted? Maybe @groovecoder would be able to say more about that. My experience with Redis so far has been that it specializes in job queuing, but I know it can be used for more than that. We're probably going to add Postres this week for record-keeping. Maybe that would be better. |
Oh, right, Postgres would likely be better. |
Could raise rejections as errors that would bubble up in the New Relic error reporting. That would give us the built-in reporting tools of New Relic around rejections. (Whether that's good or bad.) Could use Redis for storing data, just be aware that it needs some extra configuration if we want a degree of data safety comparable to Postrgres. |
Great point. It would be good to have that information in New Relic. Maybe it would make sense to fire something off to New Relic whenever |
Come to think of it, while New Relic reporting would be great, do we need to block these improvements on that? If anything, we should see fewer errors with the addition of Redis. |
Excellent! R+! |
Fix #104: Manage, throttle comments with Redis
Testing these changes:
heroku addons:create heroku-redis:hobby-dev
(you'll need to enter a credit card)heroku ps:scale web=1 worker=1
You should see 20 comments appear within a few seconds. There should be one comment for each property.
To run tests locally, see the updates in
CONTRIBUTING.md
.