News for hackers. Stuff that matters.
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by JoeyBananas on Friday July 30, 2021 @06:39PM (#28013285)
wouldn't this be vulnerable to DOS attacks? I can make the database run arbitrarily long and complicated queries
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by simonw on Friday July 30, 2021 @06:41PM (#28013304)
Since the work all happens in your browser, the only victim of a long complicated query would be you own browse and the S3 bandwidth bill of the person hosting the database (since you'd end up sucking down a lot of data).

But if you want to jack up someone's S3 bandwidth bill there are already easier ways to do it!

Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by floatingatoll on Friday July 30, 2021 @06:44PM (#28013334)
It's a static file, CDN it.
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by simlevesque on Friday July 30, 2021 @06:57PM (#28013446)
Many CDNs cannot cache 43GB files.

Cloudflare's limit is 10GB, 20GB for Cloudfront, 150GB for Akamai and Azure.

Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by phiresky on Friday July 30, 2021 @07:09PM (#28013544)
You can chunk the file into e.g. 2MB chunks. The CDN can then cache all or the most commonly used ones. That's what I did in the original blog post to be able to host it on GitHub Pages.
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by dmos62 on Saturday July 31, 2021 @06:55AM (#28017001)
I would look into caching range requests. Simpler than pre-chunking or caching the whole database.
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by sltkr on Friday July 30, 2021 @07:14PM (#28013575)
It should be trivial to split it up into 1GB chunks or whatever. In fact, if you only request single pages, you could split the database up into pagesize-sized files. This is a lot of files, but at least it avoids the need to do range requests at all. You probably want to increase the pagesize a bit though (e.g. maybe 256 KiB instead of the default 4 KiB?)
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by floatingatoll on Friday July 30, 2021 @07:58PM (#28013890)
Range requests are the star, so I would vote keep them? I mean, technically, the CDN could represent each 4kb block of the file as an individual URL, so that you do range requests by filename instead of by .. range request .. but at some point I definitely think RRs are more sane.
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by rzzzt on Saturday July 31, 2021 @04:02AM (#28016299)
Probably both, compute file name and relative offset from the original offset. (A minor complication is requests crossing file boundaries, in which case you have to do two requests instead of one.)
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by milankragujevic on Friday July 30, 2021 @07:21PM (#28013620)
Isn't Cloudflare's limit 512 MB? (except for enterprise plan which has no price defined where it's 5GB)

https://support.cloudflare.com/hc/en-us/articles/200172516-U...

Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by floatingatoll on Friday July 30, 2021 @07:57PM (#28013882)
TIL, for whatever it's worth :) Thanks!
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by jlg23 on Friday July 30, 2021 @07:03PM (#28013493)
If I get the essence of what you are saying... "the only victims would be both ends of the communication"? ;)
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by quickthrower2 on Friday July 30, 2021 @07:37PM (#28013733)
What is said is this site isn’t any more susceptible to DOS than any other site. Of all the ways of architecting a site this is probably the least vulnerable.
Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by chrisseaton on Friday July 30, 2021 @07:19PM (#28013603)
> I can make the database run arbitrarily long and complicated queries

Do you understand that the database runs on your computer? You can only DOS yourself.

Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by carlhjerpe on Friday July 30, 2021 @08:50PM (#28014182)
In a smart webserver this could mean not a whole lot more than a memcpy, and between you and the CDN it probably won't be too high latency.

One would have to version the SQLite DB by version to avoid corruption by cache invalidation.

Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by rkeene2 on Friday July 30, 2021 @10:49PM (#28014810)
My static file HTTP server called "filed" [0] will satisfy a request in as few as 1 system call (no memcpy involved -- the kernel reads the file and sends the buffer to the NIC), by using sendfile(2). Most other webservers do a bit more work, like open the file for every request.

[0] http://filed.rkeene.org/

Re:Show HN: Static.wiki – read-only Wikipedia using a 43GB S... by CodesInChaos on Friday July 30, 2021 @06:41PM (#28013302)
The database runs on the client. It can't do anything you couldn't do through any other http client.