Shared memory question
Posted: Fri May 14, 2004 12:19 am
Here is the situation.
We have some applications writing in PHP for both CLI and web based applications. There is a table with about 20k rows in it at @ 1k in size per row. We also have a related table with about 100k rows at about 30 bytes per row. We do a lot of calculations on the data provided in these rows with multiple applications. Most if it's for reporting. Many of the reports use 5k of these rows at a time.
What we have found is the we spend most of the time loading the data for each row from the MySQL database to the application. Much of the data in the database is static for the day only but updated daily. As we load the data we apply various calculations per hour to the data as it's loaded.
We spend a lot of time loading data and applying the hourly rules to the daily data. The calculations cannot be stored in the database for a variety of reasons (business requirements not technical).
We have a class that we use when loading each of the data elements. As we apply this calculation to the data it's valid for 1 hour after it's loaded. I would like to keep this in some type of shared memory until it is expired. This way the data would be available precalculated for both the CLI and the web.
I have looked as some shared memory functions in c/c++ but I would like to find out what is best to use for PHP. I know that the first thoughts would be why not add the fields to MySQL and be done with it. I would like to but because of the type of business using this we cannot store the data to disk for a variety of business/legal reasons.
What are my best options for this in PHP?
We have some applications writing in PHP for both CLI and web based applications. There is a table with about 20k rows in it at @ 1k in size per row. We also have a related table with about 100k rows at about 30 bytes per row. We do a lot of calculations on the data provided in these rows with multiple applications. Most if it's for reporting. Many of the reports use 5k of these rows at a time.
What we have found is the we spend most of the time loading the data for each row from the MySQL database to the application. Much of the data in the database is static for the day only but updated daily. As we load the data we apply various calculations per hour to the data as it's loaded.
We spend a lot of time loading data and applying the hourly rules to the daily data. The calculations cannot be stored in the database for a variety of reasons (business requirements not technical).
We have a class that we use when loading each of the data elements. As we apply this calculation to the data it's valid for 1 hour after it's loaded. I would like to keep this in some type of shared memory until it is expired. This way the data would be available precalculated for both the CLI and the web.
I have looked as some shared memory functions in c/c++ but I would like to find out what is best to use for PHP. I know that the first thoughts would be why not add the fields to MySQL and be done with it. I would like to but because of the type of business using this we cannot store the data to disk for a variety of business/legal reasons.
What are my best options for this in PHP?