{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/comments/230431971","pull_request_review_id":171175409,"id":230431971,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMDQzMTk3MQ==","diff_hunk":"@@ -0,0 +1,49 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.Text;\n+\n+namespace Microsoft.Bot.Connector.Shared.Authentication\n+{\n+    public class RetryParams\n+    {\n+        private static readonly TimeSpan MaxDelay = TimeSpan.FromSeconds(10);\n+        private static readonly TimeSpan DefaultBackOffTime = TimeSpan.FromMilliseconds(50);\n+\n+        public static RetryParams StopRetrying\n+        {\n+            get\n+            {\n+                return new RetryParams() { ShouldRetry = false };","path":"CSharp/Library/Microsoft.Bot.Connector.Shared/Authentication/RetryParams.cs","position":16,"original_position":16,"commit_id":"bcd5113058cee6f7c06d9e1bcd4015a4c7cd4e3e","original_commit_id":"bcd5113058cee6f7c06d9e1bcd4015a4c7cd4e3e","user":{"login":"carlosscastro","id":21318528,"node_id":"MDQ6VXNlcjIxMzE4NTI4","avatar_url":"https://avatars3.githubusercontent.com/u/21318528?v=4","gravatar_id":"","url":"https://api.github.com/users/carlosscastro","html_url":"https://github.com/carlosscastro","followers_url":"https://api.github.com/users/carlosscastro/followers","following_url":"https://api.github.com/users/carlosscastro/following{/other_user}","gists_url":"https://api.github.com/users/carlosscastro/gists{/gist_id}","starred_url":"https://api.github.com/users/carlosscastro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlosscastro/subscriptions","organizations_url":"https://api.github.com/users/carlosscastro/orgs","repos_url":"https://api.github.com/users/carlosscastro/repos","events_url":"https://api.github.com/users/carlosscastro/events{/privacy}","received_events_url":"https://api.github.com/users/carlosscastro/received_events","type":"User","site_admin":false},"body":"Ya, yes I had that in mind and never came back to it. Fixing now.","created_at":"2018-11-02T16:20:28Z","updated_at":"2018-11-02T16:20:28Z","html_url":"https://github.com/Microsoft/BotBuilder-V3/pull/53#discussion_r230431971","pull_request_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/53","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/comments/230431971"},"html":{"href":"https://github.com/Microsoft/BotBuilder-V3/pull/53#discussion_r230431971"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/53"}},"in_reply_to_id":230264889},"pull_request":{"url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/53","id":227783794,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI3NzgzNzk0","html_url":"https://github.com/Microsoft/BotBuilder-V3/pull/53","diff_url":"https://github.com/Microsoft/BotBuilder-V3/pull/53.diff","patch_url":"https://github.com/Microsoft/BotBuilder-V3/pull/53.patch","issue_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues/53","number":53,"state":"open","locked":false,"title":"C# Auth Token: Refactored implementation using Adal","user":{"login":"carlosscastro","id":21318528,"node_id":"MDQ6VXNlcjIxMzE4NTI4","avatar_url":"https://avatars3.githubusercontent.com/u/21318528?v=4","gravatar_id":"","url":"https://api.github.com/users/carlosscastro","html_url":"https://github.com/carlosscastro","followers_url":"https://api.github.com/users/carlosscastro/followers","following_url":"https://api.github.com/users/carlosscastro/following{/other_user}","gists_url":"https://api.github.com/users/carlosscastro/gists{/gist_id}","starred_url":"https://api.github.com/users/carlosscastro/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlosscastro/subscriptions","organizations_url":"https://api.github.com/users/carlosscastro/orgs","repos_url":"https://api.github.com/users/carlosscastro/repos","events_url":"https://api.github.com/users/carlosscastro/events{/privacy}","received_events_url":"https://api.github.com/users/carlosscastro/received_events","type":"User","site_admin":false},"body":"The old implementation, after several fixes, proved to not be robust enough. Given that Adal handles much of the token caching nowadays, we consider it better to leverage ADAL library implementation, leaving less responsibilities in our code. However, after working with the ADAL team we are still responsible for maintaining low concurrency (done through semaphores in this case) and retrying, using the retry after headers received from AAD when we get HttpStatusCode 429.\r\n\r\nWe ran long haul load test, in addition to mini-load tests and unit tests. We were able to reproduce token renewal under extremely high load, and even though there were failures, these were retried and ZERO threads ended up without a token. The longest delay observed in our load test was 600 ms, which happened for a total of 40 requests, then going back to 1 millisecond when reading from cache.\r\n\r\nEven though the ADAL team recommended limiting concurrency, we removed the semaphore and re-ran the load tests. These results were extremely bad, with latencies up to 5 seconds and multiple failures, confirming ADAL teams' recommendation.\r\n\r\nThe ADAL team is working on the MSAL library, which will take care of the concurrency control as well. Eventually we'll move to that. Also, both the current ADAL library and the MSAL library allow for custom token caches. In V4 we will expose this so that bot developers can use persistent token caches (as opposed to the memory-based default one) so that multiple instances can benefit from a single cache entry on a horizontal scaling scenario.","created_at":"2018-11-01T22:52:34Z","updated_at":"2018-11-02T16:20:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f254908ddde75bb222aec2c46b08c45f5ed8cca6","assignee":null,"assignees":[],"requested_reviewers":[{"login":"tomlm","id":17789481,"node_id":"MDQ6VXNlcjE3Nzg5NDgx","avatar_url":"https://avatars0.githubusercontent.com/u/17789481?v=4","gravatar_id":"","url":"https://api.github.com/users/tomlm","html_url":"https://github.com/tomlm","followers_url":"https://api.github.com/users/tomlm/followers","following_url":"https://api.github.com/users/tomlm/following{/other_user}","gists_url":"https://api.github.com/users/tomlm/gists{/gist_id}","starred_url":"https://api.github.com/users/tomlm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomlm/subscriptions","organizations_url":"https://api.github.com/users/tomlm/orgs","repos_url":"https://api.github.com/users/tomlm/repos","events_url":"https://api.github.com/users/tomlm/events{/privacy}","received_events_url":"https://api.github.com/users/tomlm/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/53/commits","review_comments_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/53/comments","review_comment_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues/53/comments","statuses_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/statuses/bcd5113058cee6f7c06d9e1bcd4015a4c7cd4e3e","head":{"label":"Microsoft:ccastro/token-renewal-refactor","ref":"ccastro/token-renewal-refactor","sha":"bcd5113058cee6f7c06d9e1bcd4015a4c7cd4e3e","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":148844296,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg4NDQyOTY=","name":"BotBuilder-V3","full_name":"Microsoft/BotBuilder-V3","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Microsoft/BotBuilder-V3","description":"Microsoft Bot Builder V3 SDK for Microsoft Bot Framework","fork":false,"url":"https://api.github.com/repos/Microsoft/BotBuilder-V3","forks_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/forks","keys_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/teams","hooks_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/events","assignees_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/tags","blobs_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/languages","stargazers_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/subscription","commits_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/merges","archive_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/downloads","issues_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/deployments","created_at":"2018-09-14T21:37:49Z","updated_at":"2018-11-01T20:13:23Z","pushed_at":"2018-11-02T09:38:35Z","git_url":"git://github.com/Microsoft/BotBuilder-V3.git","ssh_url":"git@github.com:Microsoft/BotBuilder-V3.git","clone_url":"https://github.com/Microsoft/BotBuilder-V3.git","svn_url":"https://github.com/Microsoft/BotBuilder-V3","homepage":null,"size":217582,"stargazers_count":11,"watchers_count":11,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":10,"open_issues":16,"watchers":11,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"669c834afd35f3267cbff1827094d98320f293a6","user":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":148844296,"node_id":"MDEwOlJlcG9zaXRvcnkxNDg4NDQyOTY=","name":"BotBuilder-V3","full_name":"Microsoft/BotBuilder-V3","private":false,"owner":{"login":"Microsoft","id":6154722,"node_id":"MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=","avatar_url":"https://avatars2.githubusercontent.com/u/6154722?v=4","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Microsoft/BotBuilder-V3","description":"Microsoft Bot Builder V3 SDK for Microsoft Bot Framework","fork":false,"url":"https://api.github.com/repos/Microsoft/BotBuilder-V3","forks_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/forks","keys_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/teams","hooks_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/events","assignees_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/tags","blobs_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/languages","stargazers_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/subscription","commits_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/merges","archive_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/downloads","issues_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/BotBuilder-V3/deployments","created_at":"2018-09-14T21:37:49Z","updated_at":"2018-11-01T20:13:23Z","pushed_at":"2018-11-02T09:38:35Z","git_url":"git://github.com/Microsoft/BotBuilder-V3.git","ssh_url":"git@github.com:Microsoft/BotBuilder-V3.git","clone_url":"https://github.com/Microsoft/BotBuilder-V3.git","svn_url":"https://github.com/Microsoft/BotBuilder-V3","homepage":null,"size":217582,"stargazers_count":11,"watchers_count":11,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":10,"mirror_url":null,"archived":false,"open_issues_count":16,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":10,"open_issues":16,"watchers":11,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/53"},"html":{"href":"https://github.com/Microsoft/BotBuilder-V3/pull/53"},"issue":{"href":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues/53"},"comments":{"href":"https://api.github.com/repos/Microsoft/BotBuilder-V3/issues/53/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/53/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/BotBuilder-V3/pulls/53/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/BotBuilder-V3/statuses/bcd5113058cee6f7c06d9e1bcd4015a4c7cd4e3e"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"carlosscastro"}}