Laravel Eloquent Tips and Tricks

Eloquent ORM seems like a simple mechanism, but under the hood, there’s a lot of semi-hidden functions and less-known ways to achieve more with it. In this article, I will show you a few tricks.

1. Increments and Decrements

Instead of this:

Tags:

Decreasing Server Timeouts

There are a variety of timeout settings in each layer of a LAMP server stack. The importance of lowering
timeout settings is that it prevents a slow or unresponsive service from causing a process load pile-up on
your web server. It is advisable to decrease all timeout settings as low as you can tolerate.

Avoiding Calling External Web Services

A web server killer we see quite often is custom Drupal modules that call out to an external web service
and that external service is slow or unresponsive. This kind of issue can quickly render your web server
totally unresponsive to page requests because soon all PHP processes are tied up waiting on an external
service that isn’t answering. The root cause is that PHP’s default_socket_timeout defaults to a generous
60 seconds, so each of your PHP processes will block a full minute waiting for a packet that isn’t coming.

Boost

The popular Boost module for Drupal (http://drupal.org/project/boost) essentially builds a static file
cache for dynamically generated Drupal content. With the Boost module installed in Drupal, whenever
Drupal generates a dynamic page, Boost will save a static copy of that content so that the next
anonymous request for that same page will be delivered from the Boost cache. A background cron
process periodically culls outdated pages from the Boost cache, which are then regenerated on the next

Caching Is the Key to Drupal Performance

The three secrets to optimal Drupal performance are cache, cache, and more cache. Every layer of the
Drupal server stack offers its own caching options, and you should familiarize yourself with how to take
advantage of all of them. Here’s a list of key areas to consider as you look for opportunities to improve
the performance of your site:

Pages

Subscribe to Front page feed