0

Consider following back-end script.

<?php

    if (isset($_GET["req"])) {
        $req = $_GET["req"];

        if ($req == "delete") {
            // Very intense calculation which finally results in deletion.
        }

        if ($req == "add") {
            // Very intense calculation which finally results in addition.
        }

        if ($req == "modification") {
            // Very intense calculation which finally results in modification.
        }
    }

?>

Let's say there's 10 people using website intensively at the same time. Does using example.php?req=modification force Apache to rerun the entire file, or does Apache cache it for better performance and ignore every other piece that does not match?

Could I use this
example.php?req=add
example.php?req=remove
example.php?req=mod

without performance loss relative to this:
/files/add.php
/files/remove.php
/files/modify.php
?

This would help in progress indication, seperating tasks instead of bunchprocessing and requesting 3 different files.

Edited by RikTelner

4
Contributors
7
Replies
37
Views
1 Year
Discussion Span
Last Post by jkon
1

As I understand it, the php module sits and listens to ports and creates an instance for each request. Therefore, without some sort of data caching, there should be no appreciable difference between the two methods you describe other than the overhead for traversing a directory.

0

Is there any other more sufficient way using PHP? You mentioned data caching, but in my case it can't quite be used, at least tutorials are not sufficient and programming the entire cache system would not be equal to headaches saved.

Edited by RikTelner

0

PHP is already pretty fast.. what is it that you are looking to do that you are having this cocern?

0

what is it that you are looking to do that you are having this cocern?

I don't like the idea of reloading the same exact file about 6 times because of 6 seperate functions. I'd rather call a certain part out of it, to spare headache for the server. On top of it, I need to learn optimization.

I don't like the idea of loading 6 different files, because they all depend on each other, REALLY heavily. Of course I could use include() but that will bring me back to 1st concern and multiply it by 5!.

1

Well... that's a design consideration... if you want a light weight landing page for quick scripts, then make one. Im not sure what heavy weight stuff you are going to be doing, but if it's a database lookup, or processing data in some way, it should be very fast. If you want to break up your pages into a recieve and process structure, that's fine too - you can use cURL at the end of the recieve script, send it off to a processing page, and be done with it. You can also spawn threads and let them take care of it as time permits, and set up a queue.

Again, depending on what you are doing, and how much work really needs to be done, you may be trying to over-optimize before optimization is a problem :-/

0

It seems that you are talking about actions and you use get. Don't. Of course post can be panipulated also , but it is the first barrier (out of many many more).

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.