0

I have a bunch of virtual host subdomains that use the same source code. Each subdomain has a row in a settings table that has the settings for the subdomain. These settings determine things like what html template to load, age rating and around 30 other settings so they are vital. Rather than query the DB every single time a page is loaded, I want to find a way to save the data for the duration of the session to reduce the load on the DB.

If i use sessions i can query the DB if the session doesnt exist and save the contents of the query to the session where i can then use the values on each page load to determine how the page should be displayed. The question here is will a huge amount of session variables for all users create a performance hit?

Alternatively i was thinking i could query the DB and save the contents of the array to a file as JSON.I could then read the file upon each page load to get the settings. This could be refreshed every hour or so and could be shared across all users on each subdomain. The issue here is will a massive amount of requests to a single json file hurt disk performance?

1 Answer 1

1

Traditionally people use Memcache. It's an in memory cache system to store key value pairs. http://php.net/manual/en/book.memcache.php

Sign up to request clarification or add additional context in comments.

2 Comments

so this is sort of like a session, but its set globally for all users of a particular domain? If its server memory then it might be an issue as the subdomains all share the same server. so if i had a variable called htmltemplate it would could potentially be different on each subdomain.
This can be solved by including the user ID and/or the domain ID in the key if the content depend of it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.