Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Side by Side Diff: net/url_request/url_request_throttler_entry.cc

Issue 7027040: Implement A/B experiment for anti-DDoS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head. Extend trial cut-off date to July 23rd. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/pref_names.cc ('k') | net/url_request/url_request_throttler_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/url_request/url_request_throttler_entry.h" 5 #include "net/url_request/url_request_throttler_entry.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 new RejectedRequestParameters(url_id_, 192 new RejectedRequestParameters(url_id_,
193 num_failures, 193 num_failures,
194 release_after_ms))); 194 release_after_ms)));
195 195
196 reject_request = true; 196 reject_request = true;
197 } 197 }
198 198
199 int reject_count = reject_request ? 1 : 0; 199 int reject_count = reject_request ? 1 : 0;
200 UMA_HISTOGRAM_ENUMERATION( 200 UMA_HISTOGRAM_ENUMERATION(
201 "Throttling.RequestThrottled", reject_count, 2); 201 "Throttling.RequestThrottled", reject_count, 2);
202 if (base::FieldTrialList::TrialExists("ThrottlingEnabled")) { 202 if (base::FieldTrialList::TrialExists("HttpThrottlingEnabled")) {
203 UMA_HISTOGRAM_ENUMERATION(base::FieldTrial::MakeName( 203 UMA_HISTOGRAM_ENUMERATION(base::FieldTrial::MakeName(
204 "Throttling.RequestThrottled", "ThrottlingEnabled"), reject_count, 2); 204 "Throttling.RequestThrottled", "HttpThrottlingEnabled"),
205 reject_count, 2);
205 } 206 }
206 207
207 return reject_request; 208 return reject_request;
208 } 209 }
209 210
210 int64 URLRequestThrottlerEntry::ReserveSendingTimeForNextRequest( 211 int64 URLRequestThrottlerEntry::ReserveSendingTimeForNextRequest(
211 const base::TimeTicks& earliest_time) { 212 const base::TimeTicks& earliest_time) {
212 base::TimeTicks now = ImplGetTimeNow(); 213 base::TimeTicks now = ImplGetTimeNow();
213 214
214 // If a lot of requests were successfully made recently, 215 // If a lot of requests were successfully made recently,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 net_log_.AddEvent( 361 net_log_.AddEvent(
361 NetLog::TYPE_THROTTLING_GOT_CUSTOM_RETRY_AFTER, 362 NetLog::TYPE_THROTTLING_GOT_CUSTOM_RETRY_AFTER,
362 make_scoped_refptr(new RetryAfterParameters(url_id_, value_ms))); 363 make_scoped_refptr(new RetryAfterParameters(url_id_, value_ms)));
363 364
364 base::TimeDelta value = base::TimeDelta::FromMilliseconds(value_ms); 365 base::TimeDelta value = base::TimeDelta::FromMilliseconds(value_ms);
365 GetBackoffEntry()->SetCustomReleaseTime(ImplGetTimeNow() + value); 366 GetBackoffEntry()->SetCustomReleaseTime(ImplGetTimeNow() + value);
366 367
367 UMA_HISTOGRAM_CUSTOM_TIMES( 368 UMA_HISTOGRAM_CUSTOM_TIMES(
368 "Throttling.CustomRetryAfterMs", value, 369 "Throttling.CustomRetryAfterMs", value,
369 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(12), 50); 370 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(12), 50);
370 if (base::FieldTrialList::TrialExists("ThrottlingEnabled")) { 371 if (base::FieldTrialList::TrialExists("HttpThrottlingEnabled")) {
371 UMA_HISTOGRAM_CUSTOM_TIMES( 372 UMA_HISTOGRAM_CUSTOM_TIMES(
372 base::FieldTrial::MakeName("Throttling.CustomRetryAfterMs", 373 base::FieldTrial::MakeName("Throttling.CustomRetryAfterMs",
373 "ThrottlingEnabled"), value, 374 "HttpThrottlingEnabled"), value,
374 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(12), 50); 375 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromHours(12), 50);
375 } 376 }
376 } 377 }
377 378
378 void URLRequestThrottlerEntry::HandleThrottlingHeader( 379 void URLRequestThrottlerEntry::HandleThrottlingHeader(
379 const std::string& header_value, 380 const std::string& header_value,
380 const std::string& host) { 381 const std::string& host) {
381 if (header_value == kExponentialThrottlingDisableValue) { 382 if (header_value == kExponentialThrottlingDisableValue) {
382 DisableBackoffThrottling(); 383 DisableBackoffThrottling();
383 if (manager_) 384 if (manager_)
384 manager_->AddToOptOutList(host); 385 manager_->AddToOptOutList(host);
385 } else { 386 } else {
386 // TODO(joi): Log this. 387 // TODO(joi): Log this.
387 } 388 }
388 } 389 }
389 390
390 void URLRequestThrottlerEntry::HandleMetricsTracking(int response_code) { 391 void URLRequestThrottlerEntry::HandleMetricsTracking(int response_code) {
391 // This is essentially the same as the "Net.HttpResponseCode" UMA stat 392 // This is essentially the same as the "Net.HttpResponseCode" UMA stat
392 // but we are tracking it separately here for the throttling experiment 393 // but we are tracking it separately here for the throttling experiment
393 // to make sure we count only the responses seen by throttling. 394 // to make sure we count only the responses seen by throttling.
394 // TODO(joi): Remove after experiment. 395 // TODO(joi): Remove after experiment.
395 UMA_HISTOGRAM_ENUMERATION("Throttling.HttpResponseCode", response_code, 600); 396 UMA_HISTOGRAM_ENUMERATION("Throttling.HttpResponseCode", response_code, 600);
396 if (base::FieldTrialList::TrialExists("ThrottlingEnabled")) { 397 if (base::FieldTrialList::TrialExists("HttpThrottlingEnabled")) {
397 UMA_HISTOGRAM_ENUMERATION( 398 UMA_HISTOGRAM_ENUMERATION(
398 base::FieldTrial::MakeName("Throttling.HttpResponseCode", 399 base::FieldTrial::MakeName("Throttling.HttpResponseCode",
399 "ThrottlingEnabled"), 400 "HttpThrottlingEnabled"),
400 response_code, 600); 401 response_code, 600);
401 } 402 }
402 403
403 // Note that we are not interested in whether the code is considered 404 // Note that we are not interested in whether the code is considered
404 // an error for the backoff logic, but whether it is a 5xx error in 405 // an error for the backoff logic, but whether it is a 5xx error in
405 // general. This is because here, we are tracking the apparent total 406 // general. This is because here, we are tracking the apparent total
406 // downtime of a server. 407 // downtime of a server.
407 if (response_code >= 500) { 408 if (response_code >= 500) {
408 last_response_was_success_ = false; 409 last_response_was_success_ = false;
409 } else { 410 } else {
410 base::TimeTicks now = ImplGetTimeNow(); 411 base::TimeTicks now = ImplGetTimeNow();
411 if (!last_response_was_success_) { 412 if (!last_response_was_success_) {
412 // We are transitioning from failure to success, so generate our stats. 413 // We are transitioning from failure to success, so generate our stats.
413 base::TimeDelta down_time = now - last_successful_response_time_; 414 base::TimeDelta down_time = now - last_successful_response_time_;
414 int failure_count = GetBackoffEntry()->failure_count(); 415 int failure_count = GetBackoffEntry()->failure_count();
415 416
416 UMA_HISTOGRAM_COUNTS("Throttling.FailureCountAtSuccess", failure_count); 417 UMA_HISTOGRAM_COUNTS("Throttling.FailureCountAtSuccess", failure_count);
417 UMA_HISTOGRAM_CUSTOM_TIMES( 418 UMA_HISTOGRAM_CUSTOM_TIMES(
418 "Throttling.PerceivedDowntime", down_time, 419 "Throttling.PerceivedDowntime", down_time,
419 base::TimeDelta::FromMilliseconds(10), 420 base::TimeDelta::FromMilliseconds(10),
420 base::TimeDelta::FromHours(6), 50); 421 base::TimeDelta::FromHours(6), 50);
421 422
422 if (base::FieldTrialList::TrialExists("ThrottlingEnabled")) { 423 if (base::FieldTrialList::TrialExists("HttpThrottlingEnabled")) {
423 UMA_HISTOGRAM_COUNTS(base::FieldTrial::MakeName( 424 UMA_HISTOGRAM_COUNTS(base::FieldTrial::MakeName(
424 "Throttling.FailureCountAtSuccess", "ThrottlingEnabled"), 425 "Throttling.FailureCountAtSuccess", "HttpThrottlingEnabled"),
425 failure_count); 426 failure_count);
426 UMA_HISTOGRAM_CUSTOM_TIMES(base::FieldTrial::MakeName( 427 UMA_HISTOGRAM_CUSTOM_TIMES(base::FieldTrial::MakeName(
427 "Throttling.PerceivedDowntime", "ThrottlingEnabled"), down_time, 428 "Throttling.PerceivedDowntime", "HttpThrottlingEnabled"), down_time,
428 base::TimeDelta::FromMilliseconds(10), 429 base::TimeDelta::FromMilliseconds(10),
429 base::TimeDelta::FromHours(6), 50); 430 base::TimeDelta::FromHours(6), 50);
430 } 431 }
431 } 432 }
432 433
433 last_successful_response_time_ = now; 434 last_successful_response_time_ = now;
434 last_response_was_success_ = true; 435 last_response_was_success_ = true;
435 } 436 }
436 } 437 }
437 438
438 const BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() const { 439 const BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() const {
439 return &backoff_entry_; 440 return &backoff_entry_;
440 } 441 }
441 442
442 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() { 443 BackoffEntry* URLRequestThrottlerEntry::GetBackoffEntry() {
443 return &backoff_entry_; 444 return &backoff_entry_;
444 } 445 }
445 446
446 } // namespace net 447 } // namespace net
OLDNEW
« no previous file with comments | « chrome/common/pref_names.cc ('k') | net/url_request/url_request_throttler_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698