@@ -0,0 +1,58 @@
1++++
2+title = "Eyre Request Cache"
3+date = "2022-06-14"
4+
5+[taxonomies]
6+grant_type = [ "Bounty" ]
7+grant_category = [ "Core Dev" ]
8+
9+[extra]
10+image = ""
11+description = "Speed up Urbit http server by implementing a cache for requests"
12+reward = "5 stars"
13+assignee = ""
14+champion = "~tirrel"
15+grant_id = "B0182"
16+completed = false
17+canceled = false
18+link = "https://airtable.com/shr4qt9t9kz7RaOIa?prefillGrant+ID=&prefillGrant+Name=Eyre%20Request%20Cache"
19++++
20+
21+
22+## Rationale
23+
24+Urbit is a personal server, but the webserving part of it is slow, which is a
25+problem for any use case that involves using your urbit as a regular webpage
26+server and handling requests at scale. However, it doesn't need to be slow. For
27+its HTTP I/O driver, Urbit uses a library called H2O, which is incredibly fast,
28+but unfortunately, Urbit cannot take advantage of that speed because every HTTP
29+request currently is routed through the slow Arvo event loop.
30+
31+Since a large amount of HTTP requests are essentially just read requests, we can
32+treat many of them as cacheable scries, which would allow the Urbit runtime to
33+fulfill them without invoking the Arvo event loop.
34+
35+This would enable Urbit users with large audiences to serve web pages to them
36+without worrying about making their Urbit slow and unusable. This would
37+eliminate the need for a pattern we've frequently seen of people putting an
38+nginx or caddy cache in front of their Urbit to mask its shortcomings.
39+
40+This is one part of a two-part bounty. This part focuses on the changes to the
41+the Eyre API on the Arvo side, and the second part focuses on changes to the
42+runtime. This part can be merged into the Urbit codebase before the runtime
43+work, but the desired speedup will not occur until both parts are in.
44+
45+## Implementation
46+
47+Eyre will store a map from URLs to clay scry paths. HTTP requests coming in to
48+eyre will first check this map, and if it matches, scries the file out of clay
49+and returns it immediately. It if doesn't match, it just goes through the
50+current normal path for HTTP requests.
51+
52+New %tasks will be created for eyre to add and remove from this map.
53+
54+A %warp request to clay is maintained for each clay file in the map in order to
55+be notified about changes to them. When notified about said changes, Eyre will
56+give a %gift to the runtime.
57+
58+reward: 5 stars