Forum

Thread tagged as: Api

Custom App woes in production

Hi there, I've built a custom app. I have a PHP file which accepts JSON and passes it to a function:

    include('admin/runtime.php');

    $Membership = new Memberships;

    $member = $Membership->createMembership($_POST);

And then the function inserts the entry in the table:

public function createMembership($data){

        $member= array();

        foreach($data as $key=>$value){
            $member['membership'.ucFirst($key)] = $value;
        }

        $Member = $this->db->insert('swt_swt_memberships', $member);

}

Locally it takes about 0.2s in production it takes about 17seconds. Any ideas?

Perch Runway: 2.8.13, PHP: 5.4.45, MySQL: mysqlnd 5.0.10 - 20111026 - $Id: c85105d7c6f7d70d609bb4c000257868a40840ab $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.13), assets (2.8.13), categories (2.8.13), collection_9 (2.8.13), perch_blog (4.6), perch_events (1.9.2), perch_forms (1.8.3), perch_gallery (2.8.6), perch_mailchimp (2.0.1), collection_6 (2.8.13), perch_moltin_orders (1.0), perch_moltin_products (1.0), swt_reports (1.0), swt_membership (2.1), perch_moltin (1.0), collection_5 (2.8.13), perch_comments (1.2), perch_members (1.4), perch_twitter (3.5.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'geolocate', 'donations', 'perch_comments', 'perch_gallery', 'perch_forms', 'perch_members', 'perch_mailchimp', 'perch_twitter', 'perch_blog', 'perch_events', 'url_helper', 'perch_moltin', 'swt_membership' );
Phil Smith

Phil Smith 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Nothing stands out other than those keys need to be sanitised.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Is the volume of data different between local and live? You might want to check any indexes on the table.

Turns out this was nothing to do with the insert. Immediately after inserting it was sending an email using mail() and that was failing on the questionable server.