Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit c338f0d

Browse files
authored
[DESIGN] Design Doc for caching in introspection dashboard app (#380)
1 parent 681cd29 commit c338f0d

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Software Design Document
2+
3+
Reference: Introspection - Caching of deployment status in Dashboard's backend
4+
<br> Authors: Samiya Akhtar, Andre Briggs, Dennis Seah
5+
6+
| Revision | Date | Author | Remarks |
7+
| -------: | ------------ | ----------- | ------------- |
8+
| 0.1 | Mar-07, 2020 | Dennis Seah | Initial Draft |
9+
10+
## 1. Overview
11+
12+
The application server that hosts that introspection dashboard has two
13+
components namely the frontend and backend components. The former is
14+
representation layer and the latter is responsible for fetching results from
15+
Azure Dev-Op API server.
16+
17+
<p style="text-align:center">
18+
<img src="azureAPICalls.png" width="400px">
19+
</p>
20+
21+
The frontend has a polling mechanism to fetch the latest result from the backend
22+
(which in turn makes HTTPS call to Azure Dev-Op API server). This can be
23+
problematic when we have multiple browser instances polling for latest results.
24+
25+
1. Too many calls to Azure Dev-Op API server
26+
2. Backend becomes the bottleneck
27+
3. Hitting the limit of API calls to Azure Dev-Op API server
28+
4. User experience is not good because of the tardiness in getting results from
29+
backend service.
30+
31+
<p style="text-align:center">
32+
<img src="multipleBrowsersToBackend.png" width="450px">
33+
</p>
34+
35+
On top of these, the frontend is not doing smart caching. E.g.
36+
37+
1. Fetch the list of deployed instances.
38+
2. For each deployed instances, fetch author information.
39+
40+
There will be _N_ numbers of fetch author API calls to the backend (and then to
41+
Azure Dev-Op API server) if there are _N_ deployment instances.
42+
43+
A better way is the cache the author information and reuse them according. This
44+
will significantly reduce the number of fetch author information HTTP calls.
45+
46+
## 2. Out of Scope
47+
48+
This design shall only address the above mentioned issues. That's
49+
50+
> How to significantly reduce the number of HTTPS call to Azure Dev-Op API
51+
> server. In dependent of the number of browsers that consume the backend.
52+
53+
## 3. Design Details
54+
55+
### 3.1 Caching in the backend
56+
57+
The backend shall make these calls to Azure Dev-Ops API Server
58+
59+
1. get the deployed instances
60+
2. get the author information
61+
3. get Manifest Repo Sync State
62+
63+
If there are _N_ deployed instances. There will be
64+
65+
1. one API call to get the deployed instances
66+
2. _N_ API call to get author information for each instance
67+
3. one API call to get Manifest Repo Sync State.
68+
69+
So we are looking at <i>N + 2</i> calls after the backend component is up and
70+
running. And these information is cached.
71+
72+
A timer wakes up at _T_ seconds to refresh the cache in the following manner.
73+
74+
1. one API call to get the deployed instances
75+
2. Check if there are new instances, if yes, make get author information API
76+
call for these new instances and update the cache.
77+
3. Check if there are deleted deployed instances, if yes, remove them from the
78+
cache.
79+
4. one API call to get Manifest Repo Sync State.
80+
81+
there shall be one call from the frontend (browser) to backend to get the
82+
deployment result.
83+
84+
Cache refresh duration, _T_ is customizable via an environment parameter,
85+
`REACT_APP_CACHE_REFRESH_IN_SEC`. During development of React UI, the value of
86+
this parameter can be set to a very high value to avoid hit the Azure Dev-Ops
87+
API.
88+
89+
## 4. Dependencies
90+
91+
None. All the implementations are within
92+
[spektate](https://github.com/microsoft/spektate).
93+
94+
## 5. Risks & Mitigations
95+
96+
### 5.1 Cache Size
97+
98+
The assumption is that the number of deployed instances, _N_ is not large. _N_
99+
is in hundreds and not in thousands. Otherwise, we have to increase the _RAM_
100+
(heap size) for the express app.
101+
102+
## 6. Documentation
103+
104+
How to change the refresh duration
105+
106+
\- end -
Loading

0 commit comments

Comments
 (0)