Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

Migrating from PHP to Java

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
5 posts • Page 1 of 1
Author
Message
Tekeli Li
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 95
Joined: Sat Jan 03, 2009 12:22 am

Migrating from PHP to Java

  • Quote

Post by Tekeli Li » Fri May 08, 2009 6:19 am

We're building dedicated content management systems for our clients, using a central framework we've built, upon which we build specifics for the site. We're hosting everything on our own machines, so basically we can exploit all the neat stuff like memory caching, custom configs etc.

I was wondering if porting the application(s) to Java would suit us better? Java (compiled) is much faster, and as a language more sturdy than PHP. Plus the biggest reason for migration would be usage of persistent data for which we use memory caching (eg. memcached), however there is overhead in pulling cached content from memory, per request, instead of accessing it directly in memory-persistent servlet that would be possible in Java.

My question is, given the two reasons I've just listed (performance), is it advisable for us to migrate to Java? Does this reason justify the migration? Has anyone migrated from PHP to Java who can share some experiences?
Top
saboya
Guru
Guru
Posts: 557
Joined: Tue Nov 28, 2006 10:28 am
Location: Brazil

  • Quote

Post by saboya » Fri May 08, 2009 12:55 pm

Java is not faster than PHP. PHP is probably the fastest thing available to serve web applications today.

Are you using a bytecode cache like APC / XCache / eAccelerator? That should speed things up by a ton.

Anyway, I don't really like Java for the web. I'd try Python instead. It's a wonderful language and there are some neat frameworks out there (Django for instance).

However, there's not much you can do regarding the memory persistance thing... Specially talking about distributed cache. Memcached is the way to go. You could try the newest memcached packages from PECL, they implement UDP support, which should be faster.
Top
elgato319
Guru
Guru
Posts: 546
Joined: Thu Sep 15, 2005 9:45 am

  • Quote

Post by elgato319 » Fri May 08, 2009 12:57 pm

Do you use some kind of opcode cache?
It speeds up PHP pretty well.
Top
Tekeli Li
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 95
Joined: Sat Jan 03, 2009 12:22 am

  • Quote

Post by Tekeli Li » Fri May 08, 2009 2:44 pm

Yes, of course, we use opcode cachers. Right now we're implementing xcache (because of compatibility with PHP 5.3), we used to work with APC. Xcache is also capable of storing variables thus memcached is not required yet. But there is still overhead in retrieving data from the cache on each request.

The only problem I see here is how fast are application servers / containers for the Java servlets, as that alone may offset any benefits of data persistence with servlets. We were considering Apache Tomcat. Of course, if we wanted pure performance, nothing stops us to rewrite the thing in C++, which we in fact considered, but then going Java seems much more plausible than C++ for many other advantages of Java over C++ (for example being higher level). Still, the way I see it, the methodology of servlets seems better performing: having containers parse the request just like any httpd server, then calling a method of already spawned class -- unlike with PHP where the files are stat'd, then code pulled from opcode cacher, then environment set up, then run, then variable data pulled from memory cache, etc...

Of course we can write some test scenarios and see for ourselves. I was just hoping someone else here ported their apps from PHP to Java and has experience to share. :D
Top
alistair
Retired Dev
Retired Dev
User avatar
Posts: 869
Joined: Fri Jul 15, 2005 12:53 am

Re: Migrating from PHP to Java

  • Quote

Post by alistair » Mon May 11, 2009 12:55 am

Tekeli Li wrote:We're building dedicated content management systems for our clients, using a central framework we've built, upon which we build specifics for the site. We're hosting everything on our own machines, so basically we can exploit all the neat stuff like memory caching, custom configs etc.

I was wondering if porting the application(s) to Java would suit us better? Java (compiled) is much faster, and as a language more sturdy than PHP. Plus the biggest reason for migration would be usage of persistent data for which we use memory caching (eg. memcached), however there is overhead in pulling cached content from memory, per request, instead of accessing it directly in memory-persistent servlet that would be possible in Java.

My question is, given the two reasons I've just listed (performance), is it advisable for us to migrate to Java? Does this reason justify the migration? Has anyone migrated from PHP to Java who can share some experiences?
Firstly when using tomcat make sure you have apr configured. It is meant to bring about significant speed improvements.

Also you will want to experiment with exactly what frameworks that you will want to use. There are many existing frameworks stripes,struts,jsf,spring MVC to name just a few. Depending on design these may or may not be suitable.
______________
Help the gentoo-java project. Visit Gentoo Java Project

what good are admin powers if you don't abuse them for personal gain - mark_alec
Top
Post Reply

5 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic