How to manage hono app that has more than 20,000 static assets?

Hi guys, So i have something like 100,000 font files that will be an option to read by an endpoint from hono worker, in other thread finally i know that i must use something like c.env.ASSET.fetch instead of readFile from node js. But now when i check the documentation there is a 20,000 max files limitation per worker version, what is that means? So how can i still use worker while my assets is more than 100,000? Thankss!
No description
3 Replies
DaniFoldi
DaniFoldi3w ago
You can upload your files to a KV namespace (or an R2 bucket, more convenient with rclone/s3 at that scale) and use your Worker to retrieve them. You can also cache them if you don't expect them to change
Ibnu Rasikh - creatypestudio.co
Hi, thanks for your reply, very helpful! I still have a couple of questions: 1. Will KV provide the same speed as Workers when it comes to asset retrieval? 2. KV only accepts strings as values, correct? So, I would need to convert .ttf or .otf files to something like Base64 or Uint8Array, right?
DaniFoldi
DaniFoldi2w ago
Workers with Assets (and Pages) both use KV under the hood, so the speed should be the exact same and KV can store binary data, Uint8Array is the raw bytes of the file, so you don't need to convert. Even better if you let it stream directly, then you don't need to buffer it into the memory of the worker, and it decreases the execution time by a few ms for large files.
Want results from more Discord servers?
Add your server