Startup company - need to decide webservice architecture. Java or Php webservice ?

Hi all,

I am working on a startup company, and this is a decision we are trying to solve.

Java webservice or php webservice ?

We will have a web UI which will be written in html, javascript. Then, our business logic - we want to have as webservice which can be called by the UI.  There is mobile verison - iPhone, iPad, Android version for this website. And we want to use the same webservice to be called by all these devices. Database we are going for mysql.

We are using Amazon EC2. Webservice is to be hosted in the amazon cloud. Scalability and performance is going to be key in our application.

Now, the question is what is the best approach for webservice development. I got opinion for Php and to use CakePhp or CodeIgnitor Php. Then, someone else mentioned to me about Ruby On Rails.

Also, there is opinion that java is better in terms of scalability and stability, and will help in long run than using php for webservice.  

While scalability is important, we also want to consider the fact that we are a startup and have to get the product at the earliest.

I know this is going to trigger a discussion. More than links, I would appreciate if you can give me some solid points on which language to choose, and pros/cons for them, and if you can give me some use case on how you dealt this with situation of choosing the right webservice.

I am in charge to make the decision. Please give me some insights on this, so I can make the best decision on this.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

If you need to get the product as fast as possible, the time  will be dependent on the available skills of your developers, and that may be crucial factor in the decision.
In highly hypothetical situation that you have all skills easily available, as a Java person, I'd rather vote for Java as the most versatile and solid. But you should certainly listen to other sides.
Wasim Akram ShaikCommented:
Before going for choosing webservice as you mentioned that you are at a startup company, check out for the resources available in your company.

Ask them in which are they comfortable as they are key persons who are going to support the webservice their decision should be taken into consideration.

From performance and scalability point of view, no doubt Java has got the best resources to deal with webservices and is more robust than PHP.

It will be better if you go for Java Webservice rather than PHP as Java Market is more bigger than PHP and you will find more java resources than PHP.

Ray PaseurCommented:
Is PHP acceptable?  Digg is a PHP machine.  Parts of Google, much of Yahoo, and almost all of Facebook are PHP machines.  In terms of scalability, security and dependability PHP is the equal of any programming platform.  Compare Ruby on Rails.  Twitter was (maybe still is, at least partially) a ROR machine.  Some have suggested that its performance and reliability problems were caused by the inflexibility of ROR, which leans in the direction of convention and away from configuration.  But that said, ROR is great for prototyping because you can get things running very fast.

Cake and CodeIgniter are frameworks.  If you need high performance you probably want to stay away from frameworks.  Same statement applies to WordPress, Joomla and Drupal.

If you live near a college that teaches computer science, you might want to take your checkbook and go over there to the computer science department.  Find their chief professor of information architecture and hire her as a consultant to help you make these early and formative decisions correctly.
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

greetings mindgardener, , , I will start my opinion with -> The quality or slackness of the developers going the website are far more important that the server side language that might be used. I use PHP because it is widely available on many many hosting companies, , But there are fundamental problems with the coding in PHP for more complex and specific server side factors, this is not to say that PHP is not an excellent language, it is, but it was made to be simplistic as it's beginning as "Personal Home Page" suggests. CakePhp and CodeIgnitor Php may not be an advantage, except for doing some things quicker but not so good for coordenated and wide scope (large with many aspects) web sites. Here at Experts Exchange Server, they use JAVA language, and I believe they really know something about server side choices. I have heard many times, in person and in forums that JAVA offers greater programming options (even thread control in some servers) than many other languages. If you look at some of the communication options here at Experts Exchange, you will probably find a way to talk to some one at EE about their use of JAVA here, and what they might think about it, EE people are usually very helpful. But again, I will say, that with out talented JAVA-PHP-ASP web programmers, you may as well use the old CGI, or any language, since their code will not be that good.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I've been developing with PHP for well over a decade now, and I'd definitely recommend it.  PHP is...
  * blazing fast to run
  * no additional compile time
  * easy to copy from one site to another
  * learning PHP is very fast

There's plenty more reasons to use PHP versus other programming languages, but those are some of the big reasons.  As with any language (and I *do* mean ANY language), code can get really messy really fast.  Implement some simple standards like templating (code is completely separate from interface elements) so designers that aren't programmers can revamp things with a very minimal understanding of business logic.

I'd suggest using a low-level framework, like CS-Content [] for this.  You can download the latest copy for free using a Subversion client from [] (the "trunk" is bleeding-edge; "releases" are static; and "documentation" has info about how it works).  It's built to be blazing fast and simple, without getting in the way.

One final suggestion: database is crucial, so just use PostgreSQL.  It's super fast and highly transactional, allowing massive schema changes within a transaction that can be rolled-back if something fails (in MySQL, for instance, the schema change would take effect even if something in the transaction fails, especially if one of the tables isn't transaction-capable).  It's so effective that I built an add-on to CS-Content that allows for scripted database upgrades: CS-WebAppLibs [] (get the code through an SVN client at []).
mindgardenerAuthor Commented:

Thanks everyone for the inputs..I had a word with CEO of our startup, and he said as the head for technology for the company, I have the decision power on this. He said, choose the technology based on what is best for the company and long term scaling and performance, and not on the resource. Just tell him what technology we are using, and we will get the resource to work on it.

One of my other team member is java person. I know java myself. So, I am kind of leaning more towards using java webservice for the startup backend. Good choice ?

The question is - is there any light weight java webservice framework to go for ? especially for MVC. Should I introduce persistance layer now, or keep it later ?

@crazedsanity - I have a question for you. The UI that runs javascript/html/css will make REST calls to this webservice, and in future version, API calls from Smartphone/Tablet native apps, then gmail browser plugin, facebook apps, etc). If team have equal resource strength for Java and Php, do you think php would be a better choice than java here ?  You mentioned PostgreSQL as a good choice. Is it good choice if I have analytics to run on it ? Is PostgreSQL and Java a good combination. There is payment module involved (customer making orders, etc), and then dashboards that will show revenue/other matrix reports. So, there is some heavy DB work to be involved here. You think PostgreSQL will be a better choice than MySQL in this ?

I can't say for certain that PHP is better than Java, as I have no experience with Java.  PHP is fast, there's no time required for loading, which makes development faster (I think Java requires some compiling, not sure though).  Anything that speeds development makes time-to-market much faster.

As for PostgreSQL, again I can't say anything as far as Java goes. But I can say with absolute confidence that PostgreSQL will scale an order of magnitude better than MySQL.  Database transactions are incredibly important, and the ability to combine schema and data changes within a transaction that can be rolled back is a MASSIVE benefit; so far, I know of NO OTHER DBMS that will handle schema changes within a transaction.  

PostgreSQL will scale pretty massively.  On one particular deployment, which was a SaaS (Software as a Service) system, we used PostgreSQL.  We had several databases, the smallest of which housed 30 million records (compressed data-only dump was several gigs).  All queries ran in sub-millisecond speed, with hardware that wasn't super high-end.  We did a stress test and managed to get 75,000 web-based transactions in under a second, and the server didn't break a sweat (the load average was virtually untouched).
You ask -> "light weight java webservice framework to go for ?", there are several Pre-Made and tested frameworks, I have heard of "Apache Axis2", which I was told was quite versatile for request data services, not sure if it's lightweight. But there are many factors in choosing your development set up, and you don't give much info on the specs needed, not that this question was about that. So you may want to get that sort of advice in another specific question about that in the java area.
Since you know Java, you may want to go with that, for me a disadvantage of java server side, is there are not many host companies that offer java setups. There is not as many software packages available for java as there are for php, because of the number of users.
I really agree with crazedsanity, I think that the PostgreSQL is better than MySQL for larger growing server side data storage, but like with PHP versus java, this does not mean that MySQL is not good.
Just for discussion consideration? What kind of opinion that you might get here would set you on a course to use PHP, or to use java. As I said there are advantages and disadvantages to each, and the web developer has more to do with a great working site, than the platform (IMHO).
mindgardenerAuthor Commented:

@crazedsanity - I am buying the point about PostgreSQL and put this option to the team for final decision. Let me see what they give on it.

@Slick812 - I was looking the option of which webservice to take (java or php) if I have resource for both of them..From the discussion above, I see that java would be a more stable option, as there is resource for the development. With that, I got the answer for the main question of php or java. I am deciding with java webservice.

Just for a discussion, would the guys here also give me some info the framework I can use for java.
That would make the answer fully complete and I can start the development work.

I know that usually frameworks takes lot of space and memory. And initial setup time is also long. I need something that is a good framework, while I can quickly get the REST webservice running. We have payment module through web, and we do online transactions. Will the framework by default support transaction and persistence, or should I add it from outside ? If I am not giving too much of info  - our product would have a combination of similar stuff of, groupon, yelp, job posting, etc. I am attaching a diagram of how the stack will look like. Let me know if you would need any additional info to help me with the right choice..
For the choice of database PostgreSQL is certainly an option, but I would suggest looking more closely at MySQL first.  The reasons are multiple:

1) MySQL has been used in tens of thousands of successful large scale applications.  It's well understood how to use MySQL when scaling to high performance.  PostgreSQL has a reputation as being a better design DB but far far less widely adopted, so there's a lot less certainty that you can take your application up to full scale.

2) Whenever you choose a platform (e.g. Java or MySQL) you should definitely consider how widely available are the skills required to use this platform?  E.g. If you chose to develop your application in Scala (like parts of Twitter) then you would have a very small pool of developers to pull from and so either you will have a hard time staffing up or you will have to accept weaker developers.  The same is true for your DBAs.  If you choose MySQL you will have hundreds of qualified DBAs to choose from.  If you choose PostgreSQL you may only have tens of DBAs to choose among.  This isn't a reflection on the quality of the technologies, just the realities of the workforce and that's critical for a startup.

3) Available tools.  There are a huge set of available tools for MySQL.  A much smaller set for PostgreSQL.  So again you will either need to pay more or accept more limited tools if you adopt PostgreSQL.

None of these reasons mean that PostgreSQL is definitely the wrong choice - but they're all things you should factor into your decision.

mindgardenerAuthor Commented:

Hi dpearson -

Thanks for the info. If I use mySQL now, at what point should I think of a db change...I put to my team on PostgreSQL, and they asked the exact question you asked - about DBA resourcing and development tools.

Lets see on this..I think by end of this week, we will make the final decision. I will keep all the points for our above decision.

Thanks all for the inputs.  
@dpearson: I'm curious as to where you get the figures for availability of DBA's experienced in MySQL versus PostgreSQL?  I would be interested to read that.

Someone that is experienced with either MySQL or PostgreSQL should find the transition quite easy.  In fact, someone with a background in MySQL would probably find the transition to PostgreSQL much simpler than the inverse: PostgreSQL is fully transactional, so it's like having all the tables setup as InnoDB.  There is no change in SQL, so as long as your DBA is actually qualified with SQL, understands how to properly build scalable databases and can properly implement normalization and efficient indexes, it shouldn't matter to them which DBMS is used (so starting with the more powerful one just makes sense).
Both MySQL and PostgreSQL could be used, but the actual SQL for either is identical or almost so, there are many practical aspects to all programming choices, besides the code used. I feel like PostgreSQL is better for larger deployments, but I can not really define what size would amount to a "Larger".
@mindgardener, You asked about a "need something that is a good framework", You have not gotten any reply that I can see. Just trying to offer a suggestion, I have seen and asked questions that are too "general", and do not give a place to begin, if I were asking this sort of question, I would do some preliminary research, and get the names of four java frameworks that seemed to be along the lines of what is needed. And ask which one of the four may be best suited for my endeavor. This way, there is some foundation for the type of framework you may be talking about ( I could not get much of what sort of framework you may be referring too, a base or programming framework, or a MCV like php joomla). And also gives experts a way to not recommend their favorite, if it is not appropriate to your needs. Still for responses to that question you may need to post a New question in the Java area.
From your ee.jpg of your process stack, I can see you have a full and large service platform planed, larger than I had thought you were doing before I saw that.
A worthwhile DBA won't care what the underlying technology is.  If they can't work with MySQL, PostgreSQL, and even MSSQL (or "Microsoft SQL Server"), then they don't actually have the necessary experience.

So back to the DBMS itself: PostgreSQL can, in the same transaction:
 * change schema across multiple tables
 * drop/create/modify indexes & primary/foreign keys
 * alter stored procedures
 * alter data

If that transaction is rolled-back, ALL CHANGES WITHIN THE TRANSACTION ROLL BACK TOO.  In MySQL, parts (or possibly all) of a transaction can and will affect the database even if it's rolled back.  If for no other reason, THAT makes PostgreSQL the winner.
@crazedsanity I think we're talking about a different sort of DBA role.  You're thinking in terms of the SQL layer itself - which certainly any competent DBA will be only too happy to work with any modern database (MySQL, PostgreSQL, Oracle and MSSQL).

What I'm talking about is the layer below that - tuning the actual database engine itself.  This for me is where the DBA really earns their pay.  They need to know the details of how precisely how each specific engine (within a given database - e.g.MySQL supports about 4 or 5 of these) lays out its files, manages memory and buffer spaces, when and how commits to disk occur etc.  This sort of stuff is completely different between each database and any DBA who tells you he is an expert in all databases at this level is smoking something illegal.

At the SQL level the DBA isn't the only expert available (your Java devs should all know SQL to varying levels and can help with query tuning).  But down in the guts of the engine, the DBA Is your only expert and they can easily get 10-100x performance improvements from that layer (which translates to 10-100x reduced cost for your databases).

It's here that you want to be drawing from a wide and deep pool.  And for MySQL and Oracle that pool is huge.  For PostgreSQL it's much smaller (and MSSQL perhaps mid sized).  The bigger the pool then the better the talent you can find (given a fixed budget and time frame to hire people).

Again this doesn't mean you should never choose Postgres - it's just you need to be aware of what you're giving up by making that choice.  (So you should definitely need the benefits that Postgres brings before incurring the cost).

@dpearson: I don't think it would take a lot to become comfortable with that layer... but having the knowledge "going in" can make a lot of difference. Point taken.
mindgardenerAuthor Commented:
Thanks everyone for the inputs. This discussion has been really informative.

We decided to go with java webservice and mySQL database. For webservice, we designed a Spring/Hibernate structure, that is custom design to meet our requirement.

Thanks for all the inputs.

Mind Gardener
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.