PHP Server Side Set Value versus Set Session - Performance/Memory Differences?

Do any of you PHP gurus know if there will be a performance or memory hit of any significance if I use Set Session versus Set Value when calculating 8-10 invoice related values doing some simple maths?

Only if you’re running IIS on Windows95 through a modem using a Netscape Beta!

:wink:

3 Likes

I don’t think those calculation will take a lot of memory. The value is being kept in memory only, the sessions will be in memory also, but it also saves to a file on disk. The session will also load again on the next server call. You should not put large data sets in sessions, only small data that needs to be shared between page loads.

2 Likes

Hahaha, agreed, but my US Robotics 36k modem was rock solid and sang a lovely tune too.

2 Likes

I am sure my first modem was a 1200 ie 1.2k !!!
Those were the days hey?!?!

2 Likes

All about the Baud! :smiley:

2 Likes

Guys come on… I’m asking a serious question and you’re in some old time reminiscing of last century’s technology! :rofl:

What I meant was not will one person see a 10 second pause in the app, bit whether sessions would use much more resource when I have 1000 people using my booking form at the same time.

Sorry for the lack of clarity… :joy:

We like to reminisce, we need to reminisce, it keeps us old folk sane!

4 Likes

@Antony

As your user base grows scalability becomes incredibly important (obviously). With this your hardware changes to keep up. We have several systems deployed with many thousands of users where sessions are created, destroyed, created, destroyed, etc (with as little as 48gb of memory on them, our higher tier servers are loaded with 768gb). The resource demand is tiny in the grand scheme of things. What you need to consider is maintenance of large projects. Removing the unnecessary repeated calls to databases, cache as much as you can client side, comment everything. Stress test by simulating user loads. Monitor your server logs, basic things. Then make small incremental changes, run test queries on your database (https://github.com/ErikEJ/SqlQueryStress). Iron out the bugs, everything must be efficient before you can have a good control to base your changes on so you can at least monitor them. Sessions really are not the overwhelming factor in providing services to tens of thousands of users. Its more about the design and deployment of your project being the most stream-lined and efficient possible. No point in worrying about sessions if your page is overwhelmed with dozens of queries, bells and whistles. Only include what is absolutely required for functionality. Function before form, and the good old K.I.S.S philosophy of Keep It Simple Stupid. Get all that in place then you can really gain an opinion of how various factor such as how session generation effects performance globally across your infrastructure. Load balance as necessary and always invest in the best possible technology that is at least 50% above what you think you’ll need, then you’ll have room to grow your operation and scale as required. Up-time and availability are everything. If your server dies your users will get pissed, and if you are in a competitive market they will shift. Be prepared for rapid uptake and then if it does not transpire you can always decrease your capacity and shrink your operation with no adverse issues, where by the opposite scenario could see your project fall flat on its face in failure, appear on Reddit, be mocked, or even worse memed… Oh the fear! :wink:

4 Likes

Short Answer
A virtually immeasurable difference which will only start to even show when your userbase grows to tens of thousands.

1 Like

One perhaps rather obvious point: use whichever option is most suitable for the task. I wouldn’t use a session if all I needed was a variable.

1 Like

Good point! Which raises the question… Is the scope of a variable in a server action confined to that server action, or to the PHP page?

I’m not sure what you mean. The server action is a PHP page.

So if I say this in a server action:

one

is the value of one available in another server action which is called from the same pagename.php file.

I know I can try it out but just haven’t got around to it! :slight_smile:

:rocket: …and opportunity! :rocket:

1 Like

I haven’t tried it either, but I’m sure it wouldn’t be.