13

I work for a company and we are always accessing an external site for information. The site was developed by an antiquated software development company who doesn't even have a website. They pretty much have a monopoly in my state since the content provider for the database only uses this extremely dysfunctional site to upload their data. The problem with this website is that it is so slow it's not even functional.

Having controlled for things like Connection speed and Browser type, it is clear that the problem lies within the website itself. So, I am thinking about redoing the site and then offering it to the content provider as a means for uploading their data. Basically, this project requires a very large database to store hundreds of thousands of names, addresses, and other types of data.

My only experience with databases is MySql, and really my only experience with dynamic content is PHP. So, yeah, I'm trying to figure out if the old PHP + MySQL combination is suitable for storing and representing large amounts of data. I have only done this on small projects, but I think the whole HTML templates with placeholders for the dynamic content would work fine.

Of course, I truly don't know why this website is so slow. Maybe it's not the DB at all. Maybe it's the server or something else. But the key thing I am trying to accomplish is to improve upon the speed and functionality of this site. I have no experience with other types of databases, so any tips / advice you can offer for doing a project like this would be greatly appreciated. Also, any tips regarding how to generally make a fast and functional site that would need to represent dynamic data from an extremely large database would also be helpful.

*Edit: I am learning python so if you think this would be a better side-scripting language then I can certainly try to implement something different than the initial plan above.

4
  • 11
    In all honesty. PHP and MySQL can handle it. Just as long as you know what you are doing. All to often I see people write sub-optimal querys or sluggish PHP code and just blame it on PHP / MySQL. If you know what you are doing. PHP and MySQL can handle it. If you do not know what you doing. It's not gonne matter if you move to Python or Postgre. It'll suck there too
    – Tjirp
    Apr 27, 2011 at 15:11
  • How large are we talking about, and how large hardware do you have to run it on? But you should definitely talk to this company: if you're paying them for data access then you can probably ask them to make it faster, or if you're willing to contribute to help - which they might not accept, they might just want to be paid to improve it - you should probably discuss that too to get their agreement to your plan.
    – Rup
    Apr 27, 2011 at 15:11
  • 1
  • Yes it does. I'm running a financial system since 2012 (MySQL+Java-jsp). My DB is around 100 GB for now.
    – Dupacteli
    Aug 20, 2021 at 3:13

8 Answers 8

18

If you do a good design, you can have very large databases in MySQL (this other question may help you). Define properly the keys and indexes, optimize your queries (EXPLAIN is your friend here). Select a good database engine.

There are a lot of things to do to get the best from MySQL.

EDIT: some more ideas...

It's also quite important the way you structure your data and the tables to make easy to write them, recover them or finding a compromise between both (depending on the use case).

Also if it grows you can use a cluster, partition your data between several MySQL databases in several machines (using a Master-slave schema for instance) it's another option.

To improve the performance you should also think on using some kind of cache for repetitive queries.

There is also tools like Vitess that help to scale a MySQL database in a similar way as the NoSQL databases.

13

If PHP/MySQL can scale to Facebook's usage, it can scale to yours. It's not necessarily the best solution for all situations, nor is scaling always a simple task.

1
  • 2
    One of the most important things that many misses when complaining of MySQL performance is indexes. Querying a table with a few 10 000 lines without an index and with an index makes a huge difference, from a few seconds down to a few milliseconds on a slow server (was running on an old pentium2 266 MHz ;) ). With indexes it was still lightning fast with php/MySQL. Apr 27, 2011 at 15:27
5

Yes, You can create large-scale applications using PHP and MySQL. You need to use some other helper tools as well, which will help scaling your app, for example load balancers.

Now the thing is you can't do that with default installation of MySQL itself. You need to understand how to balance the loads upon multiple servers. And then how to use clusters or shards. So you can do everything as long as your system is developed on top of a scalable architecture.

And don't start worrying about millions of records when you are just deploying your first version. Scaling happens gradually. You can't deploy an application which scales in just one day. You have to optimize it day by day. Remember Donald Knuth's quote "Premature optimization is the root of all evil"

Site's like HighScalability can help you understand designing better architectures on top of LAMP stack :)

=H=

1
  • 2
    The quote is of Donald Knuth, not of Martin Fowler (who maybe quoted Donald Knuth). Jun 8, 2012 at 23:37
4

You only really start to hit mysql's limit in the millions (and can still push it farther if really needed). You might take a look at mysql's spin offs, or if you are using billions, look at something like Cassandra.

Performance wise, php isn't the fasted, but should be fast enough. Try using background tasks/cron jobs for the time consuming jobs, and a lot of caching.

2

There are a few points to bring up with your question.

The first item that I notice is that you mentioned storing "hundreds of thousands" of rows. This isn't very big. My 386 server with 512M ram can handle that many rows with only a small delay. If you engineer your database correctly, then your real issue is going to be about the bandwidth (requests per second) that are going to be coming to your server.

MySQL can scale, but it is not great at it. Facebook does use PHP/MySQL for some of their services, but for the faster and more bandwidth intensive tasks they use hadoop. They also use PHP, but for their faster applications they use hip-hop to convert it to c++ and compile it.

MySQL can scale, but if you don't configure it correctly then it will fail miserably when the tables get too large. PostgreSQL scales better out of the box, but either does fine if configured correctly.

It looks like your application is bigger than you are used to, but really isn't "that" big. I would worry more about response time than database scaling in your particular situation.

1

Personally I've used MySQL as a large scale database mixed in with a PHP based reporting based website. We have a good couple many thousands of rows with about 20+ columns of data that come and go every day with constant multiple connections to the server. MySQL should be easily capable of performing most of the same functionality as a normal MSSQL, PostgreSQL, Oracle, etc... The key is to your queries and to make sure they are the best you can possibly write them to reduce the load on the server itself. Good luck with your project!

1

MySQL can handle a lot, you just need to make sure you're using the right database engine that suits your needs. I use InnoDB for mostly performance reasons, but you can use anything that's not MyISAM.

1
  • MyISAM works well for some data, if you mostly insert and read data but seldom update or delete MyIsam can be faster than many others as it uses optimistic locking. Apr 27, 2011 at 15:21
1

Of your course PHP and MySQL can handle a lot of data, if you have a good structured (well normalized) then you don't have nothing to worry about.

MySQL is used for a very very large projects, some of them are:

  • youtube
  • facebook
  • drupal
  • wordpress

Not the answer you're looking for? Browse other questions tagged or ask your own question.