permanently load enable HTTP Accept Filter FreeBSD kernel module (accf_http)

While reading articles about optimization, I read about the accf_http module.

The man page of the module is here, where you can read:

The utility of accf_http is such that a server will not have to context switch several times before performing the initial parsing of the request.

To load this module, use the following command:

# kldload accf_http

To load it at boot time, add the following line in /boot/loader.conf:

accf_http_load="YES"

To check if the module is loaded, use the command kldstat:

# kldstat
Id Refs Address    Size     Name
 1    4 0xc0400000 906518   kernel
 2    1 0xc0d07000 6a32c    acpi.ko
 3    1 0xc5e65000 2000     accf_http.ko

This entry was written by CharlyBr, posted on March 12, 2009 at 6:04 am, filed under Optimization and tagged . Leave a comment or view the discussion at the permalink.

Use multiple memcached daemons on FreeBSD

As you may know, when using memcached on 32-bit servers, processes can only address 4GB of virtual memory making the memcached daemon handle only 2 or 3 Gb of memory.

If you want to address more memory, you need to launch multiple memcached daemons.

I wrote an rc script , mmemcached, for FreeBSD to manage this.

To use it, you need to add this in /etc/rc.conf:

mmemcached_enable="YES"
mmemcached_servers="1 2"
mmemcached_user="nobody"
mmemcached_args="-c 8192 -t 2 -m 2048 -d"

Copy the mmemcached script in /usr/local/etc/rc.d for example and launch it with the start argument. With the above configuration it will launch two memcached daemons listening on ports 11211 and 11212 (mmemcached_servers parameter) with 2Gb of memory.

Configuration

Details of the rc.conf configuration:

  • mmemcached_enabled: let this script “startable”,
  • mmemcached_servers: List of the daemons you want to start. Each number is used to generate the port number of the daemon. For example, 2 will launch a daemon listening on port 11212,
  • mmemcached_user: user that will start the daemon,
  • mmemcached_args: flags to pass to the daemon.

Download

Download the script on github.

This entry was written by CharlyBr, posted on October 2, 2008 at 12:23 pm, filed under Distro, Uncategorized and tagged , . Leave a comment or view the discussion at the permalink.

Rotate Nginx log files under FreeBSD

To rotate your nginx log files, you can use the log file handler provided by FreeBSD: newsyslog.

Configuring /etc/newsyslog.conf

/var/log/nginx-access.log               644  7     1024 *     JC /var/run/nginx.pid
/var/log/nginx-error.log                644  7     1024 *     JC /var/run/nginx.pid

Before log rotation:

-rw-r--r--  1 root  wheel    104278002 Jul 16 11:35 nginx-access.log
-rw-r--r--  1 root  wheel      1509531 Jul 16 11:17 nginx-error.log

After log rotation:

-rw-r--r--  1 root  wheel        967 Jul 16 12:42 nginx-access.log
-rw-r--r--  1 root  wheel    5310443 Jul 16 12:41 nginx-access.log.0.bz2
-rw-r--r--  1 root  wheel         77 Jul 16 12:41 nginx-error.log
-rw-r--r--  1 root  wheel      37552 Jul 16 12:41 nginx-error.log.0.bz2

Links

This entry was written by CharlyBr, posted on July 17, 2008 at 7:15 am, filed under Logs and tagged , , . Leave a comment or view the discussion at the permalink.