9 Replies Latest reply on Sep 3, 2014 3:58 AM by dgurusamy

    Load Balancing - FileMaker PHP

    dgurusamy

      I can see the loadbalancing issue with filemaker server, when i send a multiple request from PHP..

       

      I have some questions below, people who having good knowledge or filemaker developers please calrify..

       

      1. How many connections(Request) we can send to filemaker server from php at a time ? which one is really managing this kind of request FMS 12 or FMS 13 ?

       

      Note: If I send 2 or 3 request at a time from PHP, then FM Server response time is 50 to 60 seconds.. If I send a single request at a time then server response time is 2seconds.

      How do i manage this multiple request with filemaker server. ?

       

       

      2. Is really filemaker server performing as good backend application ? which one is best filemaker server 12 or FMS 13 ?

       

      3. If I have database with huge data, is filemaker server response is good ?

       

      Thanks in advance!!

      Guru

        • 1. Re: Load Balancing - FileMaker PHP
          mikebeargie

          http://www.filemaker.com/products/filemaker-server/server-13-specifications.html

           

          1) The "tested" limit is 200 connections, although filemaker states 2000 connections is theoretically possible. This is sessions though, not requests. The number of requests should be unlimited inside of each session.

           

          Without seeing your code, I couldn't imagine why there is such a giant difference in your query times, I imagine though you might have an issue in the way your query is formed. Complex queries take more time to return than simple queries. Sometimes it's easier to get a larger data set returned from FileMaker, then parse it in PHP down to display a smaller result.

           

          2) FMS13 is best, it's also best for performance if you use the two-server deployment, assuming you're going to have heavy web-publishing usage with CWP. FMS12 is deprecated and will slowly lose support, being on FMS13 will give you the easiest upgrade path for future updates.

           

          3) What does "huge data" mean to you? What kind of data (containers, text, calculations)? Your data does has a significant effect on performance, if you are returning calculated results on 5 million records, it will be slow. Given your note above that you had a 2 second response, I would say your code and not your data may be the issue.

           

          You can also cache "calculation-heavy" data like summary fields on filemaker server for access via CWP. This way you're returning a static value instead of waiting for server to calculate the value and return it.

           

          FMS using CWP is a proven good technology that has many, MANY solutions that have been deployed and have been working great for years. However the performance is only as good as you've planned it to be. If you've planned it poorly, it will perform poorly.

          • 2. Re: Load Balancing - FileMaker PHP
            mdenyse

            Here’s some rules I generally live by if you have a solution that has multiple users. If only one person is ever accessing data at a time, then the items below that mention multiple requests may not be the best for performance.

             

             

            1. Validate that every layout you use via PHP is stripped to bare-bones. Put only the fields referenced by PHP on the layout. Avoid (if you can) summary fields and unstored calcs. Use portals where you can to reduce the number of requests you need to make, but don’t try to return a portal that has hundreds/thousands of rows. In that case make a separate request(s) to get those portal rows.

             

            2. Determine your max memory usage for your largest found set you’ll ever return. Echo memory_get_peak_usage(true); at the end of your script to get this number. Once you have this number, call ini_set("memory_limit" , “xxxxM"); to reduce the memory PHP will need for each session.

             

            3. Check your execution time. If it’s longer than a ‘few’ seconds then something isn’t working ‘right’. If you’re trying to return a found set with hundreds/thousands of records you’re likely to run into issues when you have lots of users hammering the server at the same time. Return smaller found sets and make multiple requests for each chunk. Even a small number of fields for a few hundred records can create an enormous XML stream sent to your PHP code. If you can, cache your data. Tim Dietrich’s FMWebFrame (http://www.fmwebframe.com) can give you this functionality for virtually free.

             

            4. Once you know your (approximate) maximum execution time, use set_time_limit() to stop scripts from hogging the server. If it’s really running for 10+ seconds, other users are going to feel the pain.

             

            5. If you’re using container fields, think about caching them in a web-visible directory. You will get a performance boost by doing so.

             

            6. Also, use a separate server for the web server if at all possible. That’ll keep all the normal web server work separate from FM Server. This is really no different than if you used MySQL - that server is almost always going to be on it’s on server somewhere separate from the web server in any heavy duty environment.

             

            7. For some solutions I’ve discovered it’s ‘faster’ to actually call a FileMaker script via CWP to perform your Find rather than build up a complex compound find with the PHP API. Again, this doesn’t hold true in all cases, but if you do have a complex compound find, it’s worth taking a look at.

             

            Your milage may vary depending on your particular solution, but the above items have served me well over the years.

             

            Mark

            1 of 1 people found this helpful
            • 3. Re: Load Balancing - FileMaker PHP
              dgurusamy
              3) What does "huge data" mean to you? What kind of data (containers, text, calculations)? Your data does has a significant effect on performance, if you are returning calculated results on 5 million records, it will be slow. Given your note above that you had a 2 second response, I would say your code and not your data may be the issue.

               

               

              There is a table having 4700 fields with 50000 records...  from the 4700 fields, 500 calculation fields.  

               

              If my php code is poor, then how the request complete in 2 seconds when i send  single user requst ?   tel me if i'm wrong.... My problem is, when i send the 2 request (both request are same) from the 2 different machine at the same time, It will take 45 seconds.. If I send the single request then its took 2seconds.

              • 4. Re: Load Balancing - FileMaker PHP
                steve_ssh

                Thanks for the helpful post Mark.  I appreciate you taking the time to compile and share this advice.

                 

                Best,

                 

                -steve

                • 5. Re: Load Balancing - FileMaker PHP
                  mikebeargie

                  Your amount of records is not huge but your schema is. 4700 fields sounds to me like your database is not even normalized. You might want to start there. 500 calculation fields is also enormous.

                   

                  As noted, without viewing your code or seeing your database, it's only speculation on what could cause that timeout. Mark below offers great advice to follow.

                  • 6. Re: Load Balancing - FileMaker PHP
                    dgurusamy

                    <?

                    require_once ('FileMaker.php');

                     

                    //connection string

                    $fm = new FileMaker();

                    $fm->setProperty('database', 'XXX');

                    $fm->setProperty('hostspec', '99.99.99.99');

                    $fm->setProperty('username', 'Admin');

                    $fm->setProperty('password', 'Admin');

                     

                    //find records

                    $PlantID = "5";

                    $Inflation = "2";

                    $Year = "2014";

                    $Status = "1";

                     

                    $findCommand = & $fm->newFindCommand('ProjectList');

                    $findCommand->addFindCriterion('Project_PlantID', "==".$PlantID);

                    $findCommand->addFindCriterion('Project_Inflation', "==".$Inflation);

                    $findCommand->addFindCriterion('Project_Year', "==".$Year);

                    $findCommand->addFindCriterion('StatusActive', "==".$Status);

                    $result = $findCommand->execute();

                     

                    if(FileMaker::isError($result)) {

                      echo "<p>Error: " . $result->getMessage() . "</p>";     

                      exit;

                    }

                    $records = $result->getRecords();

                     

                    foreach($records as $record) {

                         echo  $record->getField('Project_Title');

                         echo "<Br>"; 

                    }

                    ?>

                     

                    Mike, Pls get the sample code.. as you know that PHP request will communicate only on filemaker layouts, not filemaker tables..  then how it will take more execution time..

                     

                    with the above filemaker layout, I placed only 5 feilds..  when i hit the datbase by using this code, i can recieve  7240 records

                     

                    Note: There is no issue with database, when mulitple user play with fm pro, iwp only the issue is, when I send the 2 request to databas at a time, then im getting loadbalance issue.

                     

                    what do you mean about schema.. I’m not aware it. If you have better idea to overcome this issue. I'm ready to listen..


                     

                    Thanks for your valuable time..

                    • 7. Re: Load Balancing - FileMaker PHP
                      dgurusamy

                      Let me follow your valuable points with my php-filemaker development. Thanks for your time Mark!!

                       

                      Which one (FMS 12 and FMS 13) is best when I ask some questions below

                       

                      1. CWP support?  Is FileMaker developer done some good changes with FMS 13 when compare to the FMS 12

                      2. Can I see the good improvement with FMS 13 about the load balancing problem?

                       

                      Many Thanks !! - Guru

                      • 8. Re: Load Balancing - FileMaker PHP
                        TimDietrich

                        Guru --

                         

                        Here are a few other things that you might want to consider to improve performance:

                         

                        Caching. You might be able to pull data from FMS and cache it at the Web server level, thus reducing load on FMS and getting better performance. Whether or not caching makes sense will depend on your particular solution.

                         

                        ExecuteSQL. You might want to consider using ExecuteSQL to pull the data, instead of performing finds. I've found that the size of the payload being pulled from FMS is significantly smaller as a result - and again, like caching, you end up taking load off of FMS and improving performance overall.

                         

                        You might also want to consider combining the caching technique with ExecuteSQL. (In other words, cache the results of an ExecuteSQL call, if it is applicable.)

                         

                        If you haven't already, you might want to take a look at FMWebFrame. It's an extension to FileMaker's API for PHP, and it supports caching, ExecuteSQL, and a number of other features as well. http://fmwebframe.com

                         

                        I hope this helps.

                         

                        -- Tim

                        1 of 1 people found this helpful
                        • 9. Re: Load Balancing - FileMaker PHP
                          dgurusamy

                          Thanks Tim.. I hope this fmwebframe will help me to come out from this issue..

                           

                          but im struggling & getting err, when i try to implement Fmwebframe code to my fms 13 enviorment.. can you help me on it. I already sent an email to u..

                           

                          --Guru