4 ms·
> Despite all this, my practical experience is that filesystem is better than blobs for things like uploaded content, images, pngs and jps etc. This is especia
by tetha 9y ago
> Despite all this, my practical experience is that filesystem is better than blobs for things like uploaded content, images, pngs and jps etc.
This is especially true if you want to deliver them back to the users in the context of a web application. If you place this kind of content in a database, you'll need to serve them with your application.
If you use files for this content, you get two interesting options. For one, you can use any stock web server like nginx to serve these files - and nginx will outperform your application in this context. On top of that, it's easy to push this content onto a CDN in order to further cut the latency to the user.
- rusanu 9y agoAmen to that. Fastest database query is the one you never run.
- icebraining 9y agoIf you place this kind of content in a database, you'll need to serve them with your application. Well, not necessarily: https://github.com/FRiCKLE/ngx_postgres/ https://github.com/FRiCKLE/ngx_postgres/
- justinclift 9y agoInteresting project. Although that one seems pretty dead (2 years since last commit), this fork of it seems actively developed: https://github.com/konstruxi/ngx_postgres https://github.com/konstruxi/ngx_postgres
- rusanu 9y agoIn this case nginx is the 'application'. the requests is still going to be expressed as a SQL query, sent to the PG, parsed, compiled, optimized, executed, then the tabular response formatted as the HTTP response. Many more steps compared to a file-on-disk response. But I second that is an interesting nginx module
- icebraining 9y agoAh, but the filesystem has to do all that as well! It must receive a path, parse it, and then execute the query, with possible optimizations (eg. ext4 even has indexes implemented with hashed b-trees). A filesystem is just an hierarchical database.
- fnord123 9y ago>A filesystem is just an hierarchical database. Loosely. Today's file systems aren't transactional (i.e. acid compliance), which is a basic property that most people consider necessary for a database.
- phamilton 9y agoThat's not really a true statement. I use plenty of databases that aren't transactional beyond a single record.
- _jal 9y agoIt is a true statement. You're not a member of the set of "most people": > a basic property that most people consider necessary I use non-ACID stores for some purposes, but don't consider them real databases.
- the8472 9y agoMany filesystems are logged and provide atomic operations. You can build multi-step transactions on top of them with various operations. And with CoW filesystems you can even get read consistency. Oh, and optimistic locking also is an option.
- fnord123 9y agoAre we talking about the POSIX interface to files or is there a new transactional API that allows for atomic writes (all pages are written to disk or none are), consistency, isolation (opening a file in another process which is currently being written won't show the pages that are being written), and makes the writes always durable (sync; not fsync)?
- deleted 9y ago[deleted]
- sbov 9y agoIt's pretty easy to use a CDN with blob storage, which reduces the impact of serving it from your application.
- rkeene2 9y agoCompletely shameless plug here: My webserver[1] will outperform nginx for serving up static content like this. It has many optimizations, like not opening the file its serving (which reduces the latency of walking/interacting with the VFS layer); almost no runtime allocations on the heap (minimal stack frames and sizes as well) which can be completely disabled at the expense of logging; high performance logging which does not interfere with processing requests; the normal stuff in a fast webserver (sendfile, keep-alive, minimal code paths between reading the user request and delivering the first byte). [1] http://filed.rkeene.org/ http://filed.rkeene.org/
- tetha 9y agoColor me interested. How do I health-check this in a LB? What kind of caching headers do you give me out of the box?
- rkeene2 9y agoYou can check its health by making a request to a known resource -- they're practically free. It delivers an ETag header that it computes the first time it opens a file and maintains as long as that file is open. If it has to re-open the file it will generate a new ETag value.