Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java, PHP or Python for web application?

I'm going to write a web application for managing and tagging photos and I'd like to ask for advice on choosing suitable platform / framework.

The app will be quite simple from the user's point of view, however, I need some more complex things in the back-end side:

  • Rescaling and processing lots of images in a separate / background thread (without blocking the server / HTTP response) with the possibility of interrupting this thread by another HTTP request
  • Access to Amazon S3 storage, sending large files via network (also in a background thread)
  • Access to PostgreSQL and use complex and maybe slow SQL queries

Also, I prefer some lightweight solution (the more lightweight the better) and the speed isn't so important, but I'm limited by the memory - I will run the app on Linux virtual server with just 512 MB RAM.

I'm most comfortable with Java, but I can code in PHP and Python as well.

Which platform / framework would you suggest me to use?

like image 609
Martin Majer Avatar asked Nov 03 '22 14:11

Martin Majer


1 Answers

All three will do. However, PHP is _specifically_designed_ for writing web applications, so you will find many more resources and tutorials geared towards your use case written for PHP than for Python or Java. Also, make sure that the server that you are running has support for the technology that you choose, i.e. a servlet container for Java or the appropriate Apache module for PHP.

Note that PHP does not support threading, and all the online "PHP threading" tutorials are terrible hacks. I usually use PHP for the backend of the UI, and do the background tasks in PHP or Python started from a cron job. A good solution for getting the info for scheduling tasks for the cron job (be it written in PHP or Python) is to write them to a database with php:

mysql_query("INSERT INTO PhotosToProcess ('time', 'tmp_name', 'resolution') VALUES (NOW(), 'someName', '640')");

Even though Python supports threading, I do not like spawning a new thread from a process used to output the UI (HTML).

like image 139
dotancohen Avatar answered Nov 14 '22 08:11

dotancohen