Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

textboards

Name: Anonymous 2007-06-05 17:49 ID:4Zp/Oh3P

I want to make my own textboard in C fastcgi using files instead of a sql database.
Does it sound like a good fast idea?

I just want it to be blazingly fast.

What do you think /prog/?

Name: Anonymous 2007-06-05 17:54 ID:vFwRrJHg

lopl, you got the idea right

Name: Anonymous 2007-06-05 18:07 ID:u59cwM3T

fast? find what works best - SQL isn't bad, especially if you have a small set of servers (such as lighthttpd - I'm sure there are SQL servers of this sort). The primary advantage over a filesystem-based db is that your data is always easy to access and not dependent necessarily on complex directory structures. Also, cahcing is your friend for speed!

Name: Anonymous 2007-06-05 18:09 ID:Heaven

SQL is overkill for a text board.

Name: Anonymous 2007-06-05 18:21 ID:m9P83N0O

Protip: You think using files and directories is great? Think again. First, directories are lists, thus file access is linear with the number of files. Database indexes are trees, thus logarithmic. Second, files seem like the easy thing to use at first. But then you need to implement file locking, and you better come up with a good mechanism. Locking is a standard feature of databases. Some will allow safe reading while you write — even safe writing while you write other rows.

Name: Anonymous 2007-06-05 19:11 ID:qnqx4xmb

Having a database actually simplifies a lot of things. If you want something lightweight it's still better to go with sqlite than flat files.

Although, now that I think about it, with a textboard you only ever really need to append. I guess you could try files, it might work.

Name: Anonymous 2007-06-06 6:34 ID:k2H1dO/B

Use SQLite. Databases are just file libraries, implementing what you would implement by hand if you didn't have them. Most of them work in a client-server fashion, but embedded servers like SQLite work just like any other library, which happens to have a command interface called SQL. SQLite is like 250 KB, blazingly fast, and very easy to use.

Name: Anonymous 2007-06-06 6:50 ID:pwbLLqBE

>>7 speaks the truth. SQLite is very simple yet efficient.

Name: Anonymous 2007-06-06 6:59 ID:gxfhyc/M

The obvious answer is: HAppS

Name: Anonymous 2007-06-06 7:21 ID:ECZkpIP9

BBcode, some duck tape, and a rickrolling is all you need to write a textboard.

Name: Anonymous 2007-06-06 9:00 ID:k2H1dO/B

The obvious answer is: FAppS

Name: Anonymous 2007-06-06 14:34 ID:HkPKCEIl

>First, directories are lists
on FAT32 maybe...

Name: Anonymous 2007-06-07 0:14 ID:Heaven

>>12
So true. Use a real filesystem, get real performance. Use a toy OS with a toy filesystem, get shit performance.

Name: Anonymous 2007-06-07 3:36 ID:6yHe9Pfn

fuck sql and databases, make your own solution it will be 100x faster and more reliable.
people use databases way too much. databases are supposed to be for multiple users to keep concurrency. if you have only one user(the webpage) accessing it, its a waste.

Name: Anonymous 2007-06-07 4:22 ID:FTSaHxQ9

>>14
PROTIP: Most text boards have multiple users who read and post on them.
>>7
SQLite is made of slow and lack of features.

Name: Anonymous 2007-06-07 4:56 ID:afKM4Ap8

>>15
PROTIP: Shiichan uses flat files ;)

Name: Anonymous 2007-06-07 4:57 ID:ziADhn4+

PROTIP: You should store all the data in a single CSV file and fetch it with the Excel COM+ API for maximum ENTERPRISE compliance.

Name: Anonymous 2007-06-07 6:06 ID:Heaven

>>16
PROTIP: Shiichan is shit.

Name: Anonymous 2007-06-07 6:22 ID:iHACr94S

>>18
thread over

Name: Anonymous 2007-06-07 7:19 ID:LIdDO3N4

>>19
Not

Name: Anonymous 2007-06-07 7:50 ID:lnl/3MY2

>>18
PROTIP: both 2ch and Kareha also use flatfiles. Shiichan being shit is unrelated.

Name: Anonymous 2007-06-07 12:56 ID:6yHe9Pfn

>>15
yes i know there are multiple people visiting, but when i say user i mean entities accessing the data. a text board requires just requires one writing "user"(the script that adds a post to the data file) and one reading "user" (the script that writes the page), they reading "user" only has to read once after each write so in effect there is only one "user" and concurrency/locking is irrelevant.

Name: Anonymous 2007-06-07 12:57 ID:4GuhcJds

If your web server is limited to one connection, sure.

Name: Anonymous 2007-06-07 14:32 ID:IAPLDEyn

>>23
shut up

Name: Anonymous 2007-06-07 16:30 ID:NJL3SrSy

>>22
AND THEN TWO PEOPLE POST AT THE SAME TIME AND SHIT FUCKING BLOWS UP.

Name: Anonymous 2007-06-07 17:20 ID:6yHe9Pfn

>>25
the write script queues all the incoming posts and handles them one at a time, there is still only one user accessing the data.

Name: Anonymous 2007-06-07 17:33 ID:wDmTvpTH

>>26
 You moved concurrency handling from the file to the write script! GJ

Name: Anonymous 2007-06-08 1:23 ID:jkBr1q4Q

First, directories are lists, thus file access is linear with the number of files.
lol wut? I wonder if even the first versions of UNIX had this problem.

SQLite is made of slow and lack of features.
From what I've seen, SQLite is a lot faster than other OSS databases for small workloads, which seems to be its niche.

Name: Anonymous 2007-06-08 1:48 ID:RKkZ2Jlj

>>28
Connecting to the database takes longer with SQLite than with MySQL. Maybe if i was doing thousands of SELECTs on every connection that wouldn't matter, but for a simple text board it does end up being pretty significant. Also, lack of features.

Name: Anonymous 2007-06-08 2:12 ID:b+1W54TM

>>30
OP said it'd be a FastCGI program, which means he can just keep the database connection open since the program keeps running between requests; thus, the time it takes to connect is irrelevant. And SQLite has more than enough features for a simple text board.

Name: Anonymous 2007-06-08 3:46 ID:ia8lUjoV

don't bother with files, just limit yourself to one fastcgi process, and keep all the data in memory. maybe have a dump/import so you can shutdown and restart without losing data.

apache's fastcgi stuff should buffer input / output such that you're not waiting around for clients, which means that a simple while(true) { handle_request(); } should perform just as well as multiple processes/threads. unless you have multiple cores, i guess, in which case threads+locking would be the way to go.

you win for lack of filesystem overhead, i would advise you to design your data structures such that paging out to swap will work reasonably well.

inspired by the mailinator implementation - http://mailinator.blogspot.com/2007/01/architecture-of-mailinator.html - even though it's made of threaded jsp fail

Name: Anonymous 2007-06-08 4:32 ID:0ue43rQn

OP here
>>31
you better be joking nigger.

Name: Anonymous 2007-06-08 4:40 ID:b+1W54TM

>>32
It's actually not too bad an idea. If you don't mind the slight risk of total data loss, you could get a massive performance boost.

Name: Anonymous 2007-06-08 6:13 ID:li0J5Z9H

If you don't mind the slight risk of total data loss, you could get a massive performance boost.

VROOM VROOM HAY GENTOO BUDDY

Name: Anonymous 2007-06-08 11:31 ID:7541SlLQ

Maybe you could keep everything in memory for fast searching, but also save a file for each thread in the board. Then, when one of the threads is changed/added to, write that to a new file, delete the old file, and rename the new file to match the name of the old one. This prevents huge read-write times if you have a lot of threads, and also prevents anything from being lost if the system shuts down unexpectedly in a power outage or something. And of course, I reccomend getting saving your files on a bunch of cheap drives in a RAID 5 array.

Also, for searching, how about using merge sort and binary search?

Name: Anonymous 2007-06-08 11:39 ID:GFZdltC7

>>35
Shut up. Open that existing file and try a little something called "appending" to it

Name: Anonymous 2007-06-08 11:54 ID:7541SlLQ

>>36

NEVER SHUT UP, NEVER SURRENDER!

Name: Anonymous 2007-06-08 14:12 ID:CqX9c8Cy

WEB SERVICSE OR GTFO ALSO JAVA ENTERPRISE EDITION APPLICATINO SERVER

Name: Anonymous 2007-06-08 14:18 ID:fsRGI9jv

PROTIP: MOST PEOPLE IN THIS THREAD DON'T KNOW THE DIFFERENCE BETWEEN THREADS AND LIGHTWEIGHT PROCESSES

Name: Anonymous 2007-06-08 14:20 ID:CqX9c8Cy

>>39
PROTIP: NO SUCH DIFFERENCE EXISTS.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List