Huge Project, is Java/Freemarker the right thing for me?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Huge Project, is Java/Freemarker the right thing for me?

Dominik Bruhn
Hy,
got a long question:
I am the programmer and administrator of a big project. This project is
a huge Bulletin Board (like PHPBB you might know) with many features
around to suite the need of the users and the project. The whole thing
is currently written in PHP using a MySQL Database-Backend.
As this code grew over the last 5 Years its very ugly and got some
serious speed problems. The site takes about 1Mio hits a day on the
php-scripts (not counting the static content like css or images), so its
quite huge. Because of the ugly code Im planing a completly rewrite from
scratch. Its my own decision what Programing language and technology to
choose, my boss has no prefrences.

Currently my prefered solution would be: A Java-Servlet (no jsp),
FreeMarker as template-engine and a Database-Backend. I wrote a small
framework to make the creation of new Pages quites simpel and to do the
authentification and other things.

But several questions remain:
1. Is a Java-Servlet and Freemarker the right solution for such a huge
project? How will the speed be compared to a PHP-Script? Will it improve
or not? Are there other advices for programing languages? Python? Ruby?

2. What Server should I choose? I currently took Tomcat (because its the
standart-solution), but I don't need all the features Tomcat provides, I
only using the Database-Pool, nothing more. Is the Tomcat not gereating
a quite big overhead? I also tried to take jetty, I managed to install
but failed with the intergration of the databasepool.

3. Any other suggestions?


Thanks a lot for reading this post.

Dominik

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Huge Project, is Java/Freemarker the right thing for me?

Daniel Dekany
Sunday, January 21, 2007, 11:37:59 AM, Dominik Bruhn wrote:

> Hy,
> got a long question:
> I am the programmer and administrator of a big project. This project is
> a huge Bulletin Board (like PHPBB you might know) with many features
> around to suite the need of the users and the project. The whole thing
> is currently written in PHP using a MySQL Database-Backend.
> As this code grew over the last 5 Years its very ugly and got some
> serious speed problems. The site takes about 1Mio hits a day on the
> php-scripts (not counting the static content like css or images), so its
> quite huge. Because of the ugly code Im planing a completly rewrite from
> scratch. Its my own decision what Programing language and technology to
> choose, my boss has no prefrences.
>
> Currently my prefered solution would be: A Java-Servlet (no jsp),
> FreeMarker as template-engine and a Database-Backend. I wrote a small
> framework to make the creation of new Pages quites simpel and to do the
> authentification and other things.
>
> But several questions remain:
> 1. Is a Java-Servlet and Freemarker the right solution for such a huge
> project? How will the speed be compared to a PHP-Script? Will it improve
> or not? Are there other advices for programing languages? Python? Ruby?
>
> 2. What Server should I choose? I currently took Tomcat (because its the
> standart-solution), but I don't need all the features Tomcat provides, I
> only using the Database-Pool, nothing more. Is the Tomcat not gereating
> a quite big overhead? I also tried to take jetty, I managed to install
> but failed with the intergration of the databasepool.
>
> 3. Any other suggestions?

I'm out of Java business for a while, so I can't really tell that this
and that product is slower/faster, etc, but... I don't think you can
get too serious *speed* advantage by choosing Java VS PHP VS Python,
etc. I guess that in principle Java could be the faster, but the most
important is not the choice of language (as far as speed is
concerned), but the identification of the steps where most speed is
lost, and then optimize that. Like, maybe 80% of time is spent within
MySQL, and then no mater how fast your code is, you can't ever reach
more then 20% speedup if you don't deal with optimizing the database
things. So the important is to identify where is the speed lost. It
can loss on pretty stupid things, like forgetting to create a table
index, or even on a buggy JDBC driver, things like that. And,
FreeMarker will hardly ever be a bottleneck, so if you prefer that if
you don't consider speed, then just use that.

I prefer "static" languages, so this is why *I* would clearly prefer
Java over Python and Ruby. For me, at least when I'm working on a
bigger project, the inherently better early mistake detection of
"static" languages is very important, but maybe just because I'm such
a absent-minded guy. Well, try to write Java in Eclipse or like, and
you will see. Practically all typos you make will be underlined with
red right when you type it. Also you will have a pretty much safe
refactoring facility.

As of Tomcat Vs Jetty... chances are high that if something is
implemented by multiple organizations/companies, then that Apache
implementation is not among the best ones. Earlier I have preferred
Jetty (it was feaster to reload things with it, more logical to
configure, and in general my instinct said that it was written with
more care and professionalism), but I don't know how things stand now.

> Thanks a lot for reading this post.
>
> Dominik

--
Best regards,
 Daniel Dekany


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Huge Project, is Java/Freemarker the right thing for me?

Leos Literak
In reply to this post by Dominik Bruhn
Dominik Bruhn napsal(a):
> around to suite the need of the users and the project. The whole thing
> is currently written in PHP using a MySQL Database-Backend.
> As this code grew over the last 5 Years its very ugly and got some
> serious speed problems. The site takes about 1Mio hits a day on the

wow, this is nice ;-) Can you share with us your hardware setup?
Does mysql runs on separate server? Do you use cluster for web backend?
What CPU/RAM do servers have?

> Currently my prefered solution would be: A Java-Servlet (no jsp),
> FreeMarker as template-engine and a Database-Backend. I wrote a small
> framework to make the creation of new Pages quites simpel and to do the
> authentification and other things.

I've got similar but smaller website: www.abclinuxu.cz It is very
feature-rich and completely java-driven. I use servlets and freemarker
for MVC. During initial investigation I realized that it is much faster
combination than jsp. Jsp seems to me slow ;-) If you're curious, sources
are online under GPL.

> But several questions remain:
> 1. Is a Java-Servlet and Freemarker the right solution for such a huge
> project? How will the speed be compared to a PHP-Script? Will it improve
> or not? Are there other advices for programing languages? Python? Ruby?

hard to say. The best would be to do some performance tests. Implement
one feature, fill data and simulate the load. Then start optimizations,
deploy some caches and measure again.

How do you cache data in PHP? I do have transparent persistance cache,
that stores objects fetched from database. This means, that only the first
user must wait for DB result, all other users will be handled by cache.
I wonder, how this can be achieved with PHP.

> 2. What Server should I choose? I currently took Tomcat (because its the
> standart-solution), but I don't need all the features Tomcat provides, I
> only using the Database-Pool, nothing more. Is the Tomcat not gereating
> a quite big overhead? I also tried to take jetty, I managed to install
> but failed with the intergration of the databasepool.

I use jetty. It is very small and it has dedicated team behind with
commercial support available. If you need JNDI to bind database connection,
you have to install/configure jetty-extra package.

> 3. Any other suggestions?

Use database pools to share database connections. Creating new db
connection is very slow operation. Cache your data as much as possible.

Leos


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Huge Project, is Java/Freemarker the right thing for me?

Dominik Bruhn
Hy everybody,
I hoped for some more answers, so I push it up again.

> wow, this is nice ;-) Can you share with us your hardware setup?
> Does mysql runs on separate server? Do you use cluster for web backend?
> What CPU/RAM do servers have?
MySQL runs on its own Server (DualCore Athlon 64, 2.8GHz, 2 GB Ram), the
Dynamic Part of the Website (Tomcat, Servlet, Freemarker) will run on
another machine (DualCore Athlon 64, 3GHz, 2GB Ram) and there will be
another server for the static content (images, stylesheets). I plan to
make clustering ot the Servlet possible (Sessionstorage in a
HEAP-Database) and also make clustering of the Database possible, but
its only planed for future developments.

> I've got similar but smaller website: www.abclinuxu.cz It is very
> feature-rich and completely java-driven. I use servlets and freemarker
> for MVC. During initial investigation I realized that it is much faster
> combination than jsp. Jsp seems to me slow ;-) If you're curious, sources
> are online under GPL.
Okay, where can I find the source? As I dont speek your language Its
quite hard to find. How many hits do you get onto this website and what
hardware to you use.

>> But several questions remain:
>> 1. Is a Java-Servlet and Freemarker the right solution for such a huge
>> project? How will the speed be compared to a PHP-Script? Will it improve
>> or not? Are there other advices for programing languages? Python? Ruby?
>
> hard to say. The best would be to do some performance tests. Implement
> one feature, fill data and simulate the load. Then start optimizations,
> deploy some caches and measure again.
I implemented one of the pages in Java and run a benchmark against my
current PHP implementation. Both sites provide the same content from the
same database. The Java implementation was about 50 times faster
(really, believe me, I got the numbers). So I think Java is realy not a
bad choice.

> How do you cache data in PHP? I do have transparent persistance cache,
> that stores objects fetched from database. This means, that only the first
> user must wait for DB result, all other users will be handled by cache.
> I wonder, how this can be achieved with PHP.
I'm also planing to do this but it leads into some problemes If you want
to write servlets which can be clustered. Thats why I'm planing to Cache
the Data in a HEAP-MySQL-Table.


>> 2. What Server should I choose? I currently took Tomcat (because its the
>> standart-solution), but I don't need all the features Tomcat provides, I
>> only using the Database-Pool, nothing more. Is the Tomcat not gereating
>> a quite big overhead? I also tried to take jetty, I managed to install
>> but failed with the intergration of the databasepool.
>
> I use jetty. It is very small and it has dedicated team behind with
> commercial support available. If you need JNDI to bind database connection,
> you have to install/configure jetty-extra package.
Yould you perhaps share your jetty configuration? If I could get jetty
running I could run some benchmarks to see if its faster than tomcat.


>> 3. Any other suggestions?
> Use database pools to share database connections. Creating new db
> connection is very slow operation. Cache your data as much as possible.
Thats one of the features I use from tomcat and which I want to use if I
switch to jetty.

Thanks
Dominik

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Huge Project, is Java/Freemarker the right thing for me?

Leandro Cruz
In reply to this post by Dominik Bruhn
On 1/21/07, Dominik Bruhn <[hidden email]> wrote:
Currently my prefered solution would be: A Java-Servlet (no jsp),
FreeMarker as template-engine and a Database-Backend. I wrote a small
framework to make the creation of new Pages quites simpel and to do the
authentification and other things.


Hi Dominik, I think freemarker is a good tool for the job. I don't like jsp either.
There are other options like velocity (I'd go with freemarker) or groovy (grrovy templates or gsp)

If you are unsure, you can use a framework that handles multiple template engines at the same time, like guara (http://black-beans.com.br:8088/guara). I think freemarker will be a great tool when support for handling null references is released.

--
Leandro Rodrigo Saad Cruz
software developer - certified scrum master
:: scrum.com.br
:: db.apache.org/ojb
:: guara-framework.sf.net
:: xingu.sf.net
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel
Reply | Threaded
Open this post in threaded view
|

Re: Huge Project, is Java/Freemarker the right thing for me?

Leos Literak
In reply to this post by Dominik Bruhn
Dominik Bruhn napsal(a):
>> wow, this is nice ;-) Can you share with us your hardware setup?
>> Does mysql runs on separate server? Do you use cluster for web backend?
>> What CPU/RAM do servers have?
> MySQL runs on its own Server (DualCore Athlon 64, 2.8GHz, 2 GB Ram), the
> Dynamic Part of the Website (Tomcat, Servlet, Freemarker) will run on
> another machine (DualCore Athlon 64, 3GHz, 2GB Ram) and there will be

I thought your current setup for PHP ..

> Okay, where can I find the source? As I dont speek your language Its
> quite hard to find. How many hits do you get onto this website and what
> hardware to you use.
http://www.abclinuxu.cz/download/zdrojaky/
aka 15 thousands unique visitors a day,w hich is not bad, if linux has
~1-2% market share and my country has 10 millions of persons ;-)

> I implemented one of the pages in Java and run a benchmark against my
> current PHP implementation. Both sites provide the same content from the
> same database. The Java implementation was about 50 times faster
> (really, believe me, I got the numbers). So I think Java is realy not a

nice :-)

> Yould you perhaps share your jetty configuration? If I could get jetty
> running I could run some benchmarks to see if its faster than tomcat.

I sill use jetty 4.1, which is quite old ..

Leos


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
FreeMarker-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/freemarker-devel