Developing "Nth-Tier" Web Applications For Unix?
Kismet asks: "I've recently been involved in a largish Web application written using Microsoft tools. It consists of a UI layer written in VBScript for Microsoft ASP, a business tier of COM objects, and a backend on SQL Server 7. How can I implement something like this with Linux? It's really easy to use server-side COM objects with ASP, but is there anything that easy for PHP or Mason or something else on Linux? PHP's database stuff is neat, but I'd like to move that out of the site script."
Microsoft beats the shit out of all platforms as far as tight integration and speed of execution is concerned.I really doubt you can do that on Linux unless there is an EJB app server on linux in which case you can use JSP, EJB's to build your stuff.
If you don't mind doing Java, then I'd suggest using jsp's for the page, jboss (or enhydra) for the middle tier and Oracle for the backend. Why Oracle instead of Postgresql or MySQL? Because in both of those cases, you have to invest more logic in the middle tier since the database has anemic (postgresql) or no (mysql) support for database side processing. The last project I did used Oracle, Voyager (a corba-like Java server) and Java server pages. Worked out really, really well.
James
As for the database, I like Oracle. You could also consider keeping the database on SQL Server. Either way, you'll need a JDBC driver. Pure Java ("type 4") drivers are a pretty safe bet. WebLogic has (or had) one for SQL Server, and Oracle has a free JDBC driver for Oracle.
I think you might have got a little obsessed with the concept of a "teir" for a start.
Essentially, PHP by itself, or any language that supports abstraction, which is pretty much all of them, can be teired, this is simply dividing your program logically into n parts, and having each part communicate with the others only through a tightly defined interface.
The benefits of the 3 teir webscript/operations/database model are laid precisely in this tightly defined interface, benefits such as better security (fine-grained permissions checks can be made within the second teir, avoiding the possibility of last teir compormise, and logical simplicity within the webscripts themselves. However it is not necessary to have a three teir architecture actually run on three different applications as such.
It is entirely practical for example to, in any major database, have both the first and second teirs within the database itself. Oracle, Microsoft SQL 6/7 and the rest of the heavyweights have built in programming languages which allow you to create SQL functions, some fairly simple configuration lets you force all incoming queries to functions rather than using SQL directly, giving you the opportunity to do the second teir authentication and abstraction using the database language.
I don't particularly recommend this in the MS-SQL case at least, the language is ugly, but it does work.
The other option is to create a good library set of objects or functions in PHP say, and use that as your second teir, using require or include to pull in the libraries that do the logic work, and constaining yourself to simple operations and layout within the website PHP themselves.
If you're really set on using a COM style system, you could try something like CORBA, PHP has bindings (http://www.php.net/manual/ref.satellite.php) which allow you to talk to CORBA objects, it is probably not, at this stage, as tightly integrated as COM is into ASP, but a few functions to wrap it up should work effectively.
Personally, for most setups, I would recommend having a logical two-teir structure within PHP, I have found this to be most effective, since most of your logic is in the same language, and it is simple to map from one to another and shift the borders of the interface a bit when the client makes that irritating little request that totally destroys your design.
Having worked heavily with a system that used 4 teirs (two within PHP and two within the database) I can say that that works very well, especially letting the second database teir handle solid permissions checks etc, making it much safer in the event of kids doing strange things with your web forms (although of course you should properly filter that stuff, but its nice to have a safety net or two).
perl is similarly capable for multi-teir design, although I personally find it less usable for web work than PHP.
You can't win a fight.
I think that most of what there is out there has already been said in these few posts --
Your only real option is to use Java technologies like Java Server Pages and Enterprise Java Beans. The nice thing about this option is that many of the Java middle-tiers are cross platform. So if you ever felt the urge to host any tier of your application on a less reliable operating system, you'd be able to do that.
My perl CGI scripts -> your ASP (VB) scripts
My perl modules -> your COM objects
MySQL -> your MS-SQL database
I use mason as my top tier also. I call perl modules that do the database calls and other more complicated computation/processing. It's my understanding that that is pretty much what COM objects do.
I've mentioned this analogy before in one of those "you can't do 3 tiered architectures in linux" debates before, but I've always been disregarded as a loon with no explanation. If this analogy doesn't hold, why not?
This is definitely what the standard UNIX approach is to these kind of solutions. Weblogic is an obvious choice because it's been supported on Linux for a while. You'll find these kinds of solutions actually work much better than their COM/MTS/ASP counterparts.
Alternatively, you can go the open source route with something like Enhydra. It's not as sophisticated (yet), but it has most of what people need.
sigs are a waste of space
For great, easy-to-use, scalable open-source web application delivery, check out Enhydra by Lutris Technologies. It uses Java for easily programmable web applications, and comes with Director, which allows you to automatically connect servers for failover at the software level. Not only that, but it's free, or for a nominal fee, buy it and get support from Lutris. Also great is XMLC, which lets you take HTML (or other XML) pages, insert tags, and add in dynamic content very easily. Definitely worth at least downloading and trying out, it only takes about half an hour to learn the basics (assuming you know Java).
If it ain't broke, you need more software.
This kind of side-steps the question but...
I believe the original intention of n-tier architecture was to separate out the business logic from the data storage and presentation logic. This is still an important issue for web applications, but scalability is probably of greater importance.
If you can run your app across several machines, preferably load-balanced, you're well away. Stuff like ASP and PHP can make that kind of thing tricky (as they're built into the web server).
The site I'm helping develop at work runs the web server (3xStrongholdApache), the application server (6xDynamo) and the database (2xOracle) on separate machines. If you swap Dynamo for Enhydra all that software will run on Linux.
changed that... With WLBS, Session state is distributed, so it's possible to have working Server farms. Whether their performance/stability/religion is acceptable to you is another thing altogether, but it's no longer as tricky as it used to be...
--
Peace,
Lord Omlette
ICQ# 77863057
[o]_O
the reason most nt projects are like what you described is as much for speed as for separating everything out... consider compiling your php as an interim step to fully scalable code.
--
Peace,
Lord Omlette
ICQ# 77863057
[o]_O
As someone already mentioned ... the primary reason (these days) for going n-Tier is that you can scale by load balancing the specific layer of your application which is taking the maximum hit.
... lets graphic/page designers
Another reason (separating presentation from
other things)
work on the front end while application
developers develop the application in parallel.
Also it allows you to build different interfaces
(or even different applications) over a common
group of functionality (the business logic).
e.g. you might have an internal administrative interface for a system that has another interface open to the public internet and maybe a third monitoring and maintainance interface.
Dear dotters,
I've been working with large site for a couple of time as systems engineer. I already used BroadVision 1to1 with SSJavaScripting and Corba, ASP with relational databases and MTS among others. All I know is that PHP is much better. It has a number of good libraries, support for a level of objects, and is extremely FAST and STABLE.
Now, it's my preferred platform. I don't want to use that snowball n-tier technologies anymore. It's sure a problem in the future.
Sigh.
The future of 3-tiered development will be like this:
gui -> business logic --> data layer
xml -> php/asp/com/jsp/etc... --> mysql/oracle/ms-sql/etc...
I've played with xml. I love that stuff. No more of those messy html snippets embedded within php scripts. Yuck!
It's not just for GUI, you know :)
For a web-server you can have either:
Your database may be MySQL or PostgreSQL (my preference).
PostgreSQL can be built with TCL support (a client library loadable into a TCL interpreter) and a server-side extension allowing you to write server-side procedures in TCL (not anemic at all, IMHO). Postgres can be built to support SSL connections and comes with pgaccess -- a fairly powerfull database browsing and management GUI-tool (written in TCL/TK).
For MySQL there are also at least two TCL-extensions that provide for TCL access to its client API:
For distributed objects, etc. you could use TCL-DP. Don't let the word beta scare you -- it does wonders. The remote ends can even talk over e-mail!
And there is nothing to beat TCL/TK for a cross-platform front-end application! That's a given...
-mi
P.S. It sucks that paragraph-tags can not have attributes in /. comments. IMHO <p align="justify"> is perfectly valid and quite desirable for a paragraph with over 120 characters...
In Soviet Washington the swamp drains you.
Weblogic application server is available for Linux. It just happens to be the #1 selling EJB app server out there.
There are also open source C++ app servers out there which will outperform (and obviously out integrate since the source is right there) an MS solution. It's just that you have to be crazy (or Microsoft) to put all that effort into the solution when there are J2EE approaches which are much easier.
sigs are a waste of space
Please ignore the message I'm replying to. I was an idiot for the most part. And I recommend to fellow /.'ers not to reply to posts after working more than 30hrs, you produce drivel :/
:)
I think I have an interesting point on the reduction of necessary teirs by using the benefits of the open source model (good protocol cooperation and source modification) but for the most part that post was long winded and silly, and not only that but I didn't re-read the original question so my ranting about the question being about Open Source software was totally bogus.
I'll promise to be better next time
You can't win a fight.