> From: Rick Smereka
> I am near the end of a project writing a D3 web server. It serves
static
> and dynamic (BASIC) pages.
I'm curious why you decided to build the web server component into the
DBMS. A few of us did this with HTTP, SMTP, FTP, IRC, and other
protocols from 1995-2005,but then almost everyone stopped pursuing
that kind of development. Even Coyote, the most well-known MV web
server, was pretty much feature-complete by 1998 or so. It's raison
d'être was at an end when native environments like AP/Native and
AP/Pro went extinct and everyone was able to use "real" web servers
for all of their needs. And the NuWiki from Binary Star never really
took off either, given the plethora of free wiki platforms already in
existence. Building servers into MV platforms is cool and all, but
people spend years on other tools like that, like Apache, IIS, Casini,
lighthttpd, nginx, etc... I've learned that's usually better to
respect the work of others who specialize in these things, and
integrate with fine quality software, rather than trying to compete. I
wrote about this a few years ago here:
http://nebula-rnd.com/blog/tech/mv/2009/08/mv-to-anything.html
I'd be especially curious about your security and whether you can
support SSL. What about certs?
What about standard error return values (301, 404, 500, etc)?
What about Ajax and JSON, and handling different MIME types
(supporting REST or SOAP)?
And what about DoS attacks? What happens when a script kiddie hits
your host with a thousand simultaneous requests, or with one request
with a 20MB payload?
If you're using %sockets, are you aware of how sensitive D3 Windows is
when functionality as a socket server?
Do you support listening on any socket port or is it only 80?
What about session pooling? How are you handling load of two inbound
clients when one of them is doing a Select that takes 30 seconds, or
when one of them is returning a huge payload? Is every client request
processed by a different DBMS session=license?
Does the server support GET, POST, and DELETE separately?
Those are features provided by web servers. A web server doesn't just
serve up web pages. It supports security, concurrency, state, partial
page requests, and many other functions. I don't know how much time
you've invested in this but unless you can answer those questions
adequately then you'll need to put in more time - or change your
approach.
It's going to be tough if this is a commercial venture. D3 includes
free tools for web services now, which are easy to call from a common
(and free) web server. Of course that's different, but you'll need to
provide compelling value to compete with free. D3 also supports
FlashCONNECT.
> There are a couple of development issues that I would like to
discuss. I
> am getting this nagging feeling that there is a better way to
implement
> a couple of things.
>
> The project name is W3. The dynamic pages have the extension 'w3b'.
I immediately think of how everything in FlashCONNECT starts with 'w3'
but I guess that doesn't matter.
> The server has one D3 file of web pages and blob indexes called
> W3PAGE.
>
> Static pages have the extension 'html' and are stored as-is in an
item.
> The item ID is the full path and name of the page (eg: /index.html).
> This includes the path separators.
We've discussed here a few times the relative merits of using "real
data" as item keys, and the is consensus is that it's a bad idea.
Never use last names, phone numbers, SS#, or anything meaningful as an
ID, because undoubtedly you'll have a need to change it later. A
company that uses some other company's product key is up a creek when
that other company decides to revise their SKUs. And someone in the
company might decide it's a bad idea to send order IDs beginning with
T to Walmart because you're already using W to prefix all Walgreens
orders. Just don't do that - and don't use real page names as ID's
either. Do what they do in CMS packages. All resources get a unique
sequential ID. You can assign an alias to an ID as well as a category,
so path category/alias.html gets that ID. You can also create a table
that allows access to various aliases or IDs based on patterns. So
products/telephones/lg/p999 gets you to the same place as
/smartphones/lg999. You can also use this to setup 301 redirects since
you probably don't have .htaccess and to handle requests for
robots.txt, and other common files.
> Blobs are not stored in D3. They are stored on the host operating
> system disk and loaded at run time. The D3 blob item contains the
path
> and file name of the blob in the item ID and the operating system
path
> and file name in attribute one.
>
> Dynamic pages are flash compiled BASIC modules (not cataloged) and
> loaded dynamically at run time by the D3 'call @var()' construct.
The
> compiled module is stored in W3PAGE with the item ID as the full
path
> and file name of the web page.
I hope you validate requests against your W3PAGE dictionary before you
use call @var, otherwise it will abort right there. Call @() is also
very expensive because it needs to resolve dynamically. There are
other ways to do this.
> I have plans to port W3 to other MV systems.
I suspect you'll get either (a) much less feedback from people who
are already using common web technologies, or (b) the feedback will be
much more brutal than what I'm dishing out here. So be prepared...
> These design decisions seem to work well until I realized that it is
> probably not a good idea to have forward slashes in the item ID. D3
> does not seem to mind this but it refuses to compile a BASIC module
> with a slash in it's name (eg: SUBROUTINE /index.w3b()). When I
> create sample dynamic pages, I eliminate the entire path and only
use
> the module file name and extension.
Suggestion 1) don't use real page names as program or item IDs.
Suggestion 2) if you really need to make dynamic Calls, write a code
generator that creates a jump table from existing page names. So a
table translates page /smartphones/lg999 to program SMART1, and you
generate a program that says:
CASE PATH = "/smartphones/lg999" : CALL SMART1(params)
Of course that means all page updates need to have that program
regenerated, but that could be a small price to pay here. You might
say "for a large site that's not practical" and I'd say "a large site
would be using Apache or IIS".
> I also have concerns about how long (in characters) the item ID can
be.
> I realize that there is no practical limit in most MV environments
but
> many of those environments only consider a portion of the item ID as
> significant (I think?). This situation may lead to multiple pages
being
> considered as having the same name. Since I am storing the full path
> and page name in the item ID, there will be a lot of items that are
long.
Yeah, that's another problem with the scheme, and there will be more.
Don't try to solve these cascading problems, change the approach and
all of the problems disappear.
> To compensate for the length of the page path/name, I was thinking
of
> having an index list in the W3PAGE file where each line in the item
> would have a random series of characters followed by a space and the
> page full path and file name. Web pages would then be stored in the
> W3PAGE file with the item ID of the random series of characters.
>
> Ideas anyone...
> TIA
> Rick Smereka
That's where I was going above, but of course we both know the ID
isn't going to be "random". Rather than using a single cross-reference
item, I think a file with one or more items per page/resource would be
better. It will be easy for your single item to get seriously bloated
and you'll find yourself wanting to re-design that. This follows a
common example where old MV apps were written with a list of order
detail record IDs stored in an order header. As soon as you get a
thousand lines of detail it becomes apparent that this model doesn't
work. Or put a thousand open orders in a customer master and you'll
come to the same conclusion. No, single item's aren't good for that,
use a file of items where space isn't an issue and where you can
easily modify the structure.
HTH
Tony Gravagno
Nebula Research and Development
TG@
remove.pleaseNebula-RnD.com
http://Nebula-RnD.com/blog
Visit
http://PickWiki.com! Contribute!
http://Twitter.com/TonyGravagno