I have VPS with next configuration:
CPU: 4 X 2.4 GHz
RAM: 8GB
160 GB SSD DISK
OS: CENTOS 7
CPANEL
400 MB/S PORT SPEED
Server is located in Lithunia, Vilnius.
I have created Tracking Pixel with PHP for my partner websites.
pixel.php
<?php
$im=imagecreate(1,1);
$white=imagecolorallocate($im,255,255,255);
imagesetpixel($im,1,1,$white);
header("content-type:image/jpg");
imagejpeg($im);
imagedestroy($im);
ob_start();
require_once 'config/DB.php';
// SET COOKIE
if(!isset($_COOKIE['uid'])) {
$guestcookie = sha1(time() . rand() . $_SERVER['SERVER_NAME'] . rand());
setcookie('uid',$guestcookie);
$_COOKIE['uid'] = $guestcookie;
}
if(isset($_COOKIE['uid'])) {
$guestcookie = $_COOKIE['uid'];
}
$ip = $_SERVER['REMOTE_ADDR'];
$stmt = $db_con->prepare("INSERT INTO pixel1(uID, IP) VALUES(:uid, :ip)");
$stmt->bindParam(":uid", $guestcookie);
$stmt->bindParam(":ip", $ip);
$stmt->execute();
?>
But when there is about 20,000 request to my tracking pixel in 1 minute, Pixel.php
only inserting about 1,500 rows in MySql Table, and after that, my server and website works badly.