How to Speed Up Uploading Multiple Files via HTTP

A few months ago, I worked on a research task to find out how to improve the speed of multiple HTTP connections from one server (playing a client role) to another server (playing a server role when uploaded files are eventually saved) at the same time. In this specific issue, both servers belong to the same network. That is, we can make any change we want though allocated resource does matter.

After measurement and looking at a few layers, we found out three points to improve this connection:

  1. Implement persisent connections (keep-alive) on the server side, then the client side. If this is not implemented, after uploading a file, the related TCP connection is closed. When the next file is uploaded, a new TCP connection is constructed and this process takes quite a bit of time. It even takes more time than transferring the huge data via our network.
  2. Implement con-currency connections. That is, instead of using a single TCP connection, the client side starts a few connections at the same time, and send data via these connections. We may test and choose the optimal number to optimize the concurrency.
Continue reading “How to Speed Up Uploading Multiple Files via HTTP”

add_action – WordPress and SICP

I am going through the well-known Structure and Interpretation of Computer Programs book and come across a mention about add_action.

This immediately brought my attention as WordPress has a similar concept called hooks (add_action and add_filter). Section 3.3.4 of the book gave an example of how this concept is deployed, which is simple but brings a lot of flexibility to the system.

Such an enlightened and connected feeling!

Woo Viet 1.5.0 and OnePay Gateways

It has been one year since my previous release 1.4.5 for Woo Viet – WooCommerce for Vietnam. In this version 1.5.0, I focused on two main issues:

I tracked this version with the milestone feature in GitHub.

Continue reading “Woo Viet 1.5.0 and OnePay Gateways”

WordPress: Detect Homepage on Functions.php

Sometimes you may want to write code that triggers a hook in the homepage of your WordPress site. You try using this code:

// Wrong way if you want to use a hook
// DO NOT USE THIS
if ( is_home() || is_front_page() ) {
  // Add a hook (filter/action) here
}

It can not work because these functions can be really triggered in WordPress template files only. More specifically, they can only be triggered after the main WordPress query is run.

A simple workaround looks like this and actually it can apply to any site, not just WordPress:

// Correct way if you want to use a hook
if ( $_SERVER[ 'REQUEST_URI'] === '/' ) {
  // Add a hook (filter/action) here
}