r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[!Cheyenne] Discussions about the Cheyenne Web Server

Pekr
18-Feb-2009
[3944x3]
Imo you are wrong.
What you describe would mean, than you can only do one CGI request 
at the time. Cheyenne will launch new CGI process at each request, 
hence your file operations could collide. I like SQLite very much, 
but they don't provide server level functionality. They are able 
to work at file-lock level, but dunno how solid it is ...
If Cheyenne would be able to share handlers between apps, you could 
write small queue handler for db request and use small sqlite DB.
Janko
18-Feb-2009
[3947]
hi Pekr.. no I am not using sqlite .. I am using normal files with 
rebol blocks via LOAD
Pekr
18-Feb-2009
[3948]
Janko - renting external box is not what I regard being a deployment. 
You can't easily request all your customers to move their already 
existing sites to your new hosted server. That is not much practical, 
but I do understand your reasoning ...
Robert
18-Feb-2009
[3949]
Server rental is OT.
Pekr
18-Feb-2009
[3950]
I was just trying to say, that even with SQLite (which solves some 
file access sharing problems), you are accessing one file from multiple 
processes.
Robert
18-Feb-2009
[3951]
Is Cheyenne REST ready?
Janko
18-Feb-2009
[3952x2]
I am not sure if cheyenne starts new process for each request , I 
suspect it uses async sockets and serves request at a time
ok, that is true .. if some company has a website and wants some 
additional app there it's not good option to say relocate it all 
to vps..
Pekr
18-Feb-2009
[3954]
Janko - Cheyenne uses Uniserve multiplexing server IIRC. And AFAIK, 
Uniserve uses two aproaches - if the request can be served quickly, 
you can use one process, but if your request could last longer, you 
define handler or something like that, which spawns new process ...
Robert
18-Feb-2009
[3955]
Janko, if you can ensure that only one request accesses one file 
than you are safe. If not, the last writer will win. But no data-corruption 
will happen.
Janko
18-Feb-2009
[3956]
yes, that is another problem and I am aware of it (basically that 
is not a problem here).. the last writer wins... I am just worried 
if any data corruption can somehow happen
Pekr
18-Feb-2009
[3957]
I think that Robert is very brave with his statement :-) I would 
not bet if data can or can't be opened. If file is not locked, and 
you use write on it, and another process too, you can corrupt data, 
no?
Janko
18-Feb-2009
[3958x4]
that is the same if you have a simpler mysql based webapp.. one person 
starts editing text, another person starts editing , first saves, 
second saves.. first person looses the changes.. that is basically 
problem on application level and is the same here as if using RDBMS
I suspect on the system level at the time one write is in action 
file is locked for all other writes
and if server is uniprocess that can't happen anyway
(if - I am not sure I know exactly how cheyenne works)
Robert
18-Feb-2009
[3962x2]
Petr, the filesystem will ensure that this won't happen. The thing 
is, that for the time you write to the file, you get a file-lock. 
But this is immediatly released after you finished. So, if you try 
to write to a file with a lock, you get an error.
A DB handles this by having one file lock for the database file all 
the time, taking several request at the same time and doinga  DB 
locking scheme on-top of the filesystem locking.
Pekr
18-Feb-2009
[3964x3]
Robert - I can understand, but you access one DB file from separate 
processes, hence separate DB engines.
Is here any DB related group?
DB Chat?
Janko
18-Feb-2009
[3967x2]
Robert - thanks for explanation.. I should of known these things 
but I have been in mysql world too long :)
Pekr a little help for the problem when a existing apache/lamp website 
needs additonal web-app that you would want to write using cheyene 
would be to use Apache's mod_proxy to map just some path to cheyenne 
 > ProxyPass > ProxyPassReverse  -- http://httpd.apache.org/docs/2.0/mod/mod_proxy.html
Dockimbel
18-Feb-2009
[3969]
Cheyenne serves static resources from the main process (UniServe 
process), but CGI and RSP are executed by pre-forked worker processes. 
So yes, writing to the same file from RSP script can be an issue 
if you don't have a mean to ensure that write accesses are serialized. 
I had that issue recently for RSP log/debug file, I had to build 
a small logger service in the main process to be able to serialize 
 write access (after stress testing different file locking solutions 
from REBOL, no one seemed reliable enough to me). 


I thought about adding a synchronization service in Cheyenne that 
could be used to (but not only) address the write file sync issue. 
That could work for low sync needs (like writing to a file once every 
few seconds), but for massive sync needs (dozens or hundreds of sync 
req/s), I'm afraid that the TCP port overhead would be too costly...(maybe 
a separate sync server process with persistent TCP connections could 
be good enough even for heavy uses?)
Janko
18-Feb-2009
[3970]
aha, so rsps work on multiple worker processes, interesting.. well 
I think to me it's not a problem as each user has it's own data files 
so it's hard to imagine multiple writes could happen at the same 
time for the same file. And if I would need something reall y heavy 
duty I would make a server serving files and caching them in ram 
for speed etc, which would also take care for sync. or something 
off the shelf
Dockimbel
18-Feb-2009
[3971]
If you have a page with 2 (or more) frames, each pointing to RSP 
scripts that may all write to user's data file...that could be a 
problem. Same issue if your user opens 2 browser windows, or several 
users using the same account...the risks are not very high, but such 
cases can happen.
Janko
18-Feb-2009
[3972x2]
since processing of requwest seems to take just 1ms I think chances 
per user are slim. What would happen in it collides? would one of 
processes "get file access error" or something worse can happen by 
your exp? (I was asking about the fear of file getting corrup / half 
written before)
uh I a sleppy already it seems "happen in it collides" = "happen 
if it collides"
Oldes
18-Feb-2009
[3974]
Hard to say, but I guess that the second.
Graham
18-Feb-2009
[3975]
There are some wrappers for imagemagick on windows ... but I'm not 
aware of anyone having done that in Linux.  Maybe the qtask guys 
have done that as they use imagemagick ...
Oldes
18-Feb-2009
[3976]
It should work with .so as well... I can check it when I will be 
under linux. If you need just the conversion, it's easy.
Graham
18-Feb-2009
[3977]
Let me know how it works :)
Dockimbel
19-Feb-2009
[3978]
You can get file access errors and corrupted data in file (last write 
wins probably). A simple RSP page may be rendered very fast, but 
there's situations where it can take much more time. Imagine a complex 
query on database or using CALL to a third-party command-line tool.


With RSP pages rendering in a few ms, the risk for collision is very 
low, but it's not zero.
shadwolf
19-Feb-2009
[3979]
but in this case will be cheyenne slow or the database itself ?
Robert
19-Feb-2009
[3980x5]
There are two things to distinguish:

1. You need a locking strategy on OS/Filesystem level. On Windows 
take a look at the LockFileEx for example, to see how it is handled.

2. Depending on your app, you get/have an application specific locking 
concept. That's what SQLite for example does. This concept than is 
implemented using the different OS calls.
Because different OS use/support different functions, it's a platform 
specific implementation. Smartphone for example most likely don't 
have any locking support at all. So, the app has to fake it completely.
If you just work with plain files, you have to do 2. on your own 
our ensure that files are never accessed by two seperate running 
processes. Faking an exclusive lock is not that easy. You have mostly 
three options:

1. pessimistic locking strategy
2. optimistic locking strategy using conflict counters
3. academic locking strategy
Oh, and if you really think that's it about it. Wait: If your files 
is on a Samba network share you have to deal with the Samba way of 
locking, not the OS where the file is stored on. And Samba locking 
can be problematic as well.
REST & XMLHttpRequest: This question vanished yesterday. Is Cheyenne 
REST compatible?


And, has anyone done a simple way to request an RSP page and put 
the returned content into the DOM of a current page? Or, which JS 
framework would be best to take stuff and put it into the DOM?
Oldes
19-Feb-2009
[3985]
I don't know what is REST but I see no reason why XMLHttpRequest 
should not be possible. And I would use JQuery.
Robert
19-Feb-2009
[3986x2]
REST uses not only POST and GET but UPDATE, DELETE and INFO (IIRC) 
in HTTP requests. And I don't know if the other two need special 
treatment in the web-server or if everything is just routed to RSP 
Page and that's it.
JQuery: Looking at it already.
Janko
19-Feb-2009
[3988x3]
Robert: maybe this? http://rebol.wik.is/Cheyenne/Mod-rest
thanks for all info.. to me it's important difference if (1) last 
write wins or (2) data get's corrupted meaning you get file that 
doesn't have a rebol data that could be load-ed any more. Well I 
think I have been asking too much and should try experimenting and 
looking what happens. If only (1) can happen with very small probability 
(because I have many separate small files which don't get edited 
most of the time) in case of my current app it seems ok, but I will 
test (also what happens with read and write at the same time.) If 
(2) can happen at all then I will use/make a centralized file/data 
server right now so webapp will access no files directly any more 
and that server will have to take care of locking or serialize all 
reads writes.
I will have a "lab" project today with a title "Try to make a corrupt 
file" , this will be fun
Robert
19-Feb-2009
[3991x2]
Janko, thanks for the link. Cool!
It's (1) if you work with filesystem files AND Rebol uses the OS 
system locking functions (which I expect).
Graham
19-Feb-2009
[3993]
Robert, that's as far as I got with mod-rest ...let me know how you 
get on.