L
L
LAisen2022-03-29 09:35:08
PHP
LAisen, 2022-03-29 09:35:08

Low connection speed to the web server, what is the reason?

Good afternoon!
At work, they set up a simple server on Apache2 + PHP + MySQL on Windows (because none of us knows how to use linux) with a white IP. The task of the server is to accept files and comments to it, and write the link to the file and the comment to the database, which in turn is displayed in a table on the front (wordpress as a shell :).
When I tested it on a local machine, the files loaded instantly. After I put the server on another machine (with a white IP), files are loaded on it at a speed of 1 Mbps, when the speed is 100 Mbps from the provider. Through Speedtest I checked the speed declared both on the client machine and on the server.
I just can’t understand where the bottleneck is, which cuts the speed to 1Mbps.

Oh, and the server is certainly not super cool in terms of security. I don’t really understand anything about this, Google is to help, but Google did not help with this problem.

Files with comments are uploaded via a form on the front, passed via Ajax to a php script, which, in turn, does everything with the received data and puts the files in a folder, and the data with a link in the database.

Form code
<!DOCTYPE html>
<html>
  <head>      
    <meta charset="UTF-8">
          <title>test</title>
      <script type="text/javascript" src="/js/jquery.js"></script>
      <script type="text/javascript" src="/js/form2.js"></script>
  </head>
<body>
          <form id="otpravka" action="/insert.php" enctype="multipart/form-data" method="post">
            <p>
              <label for="Sub_division">Подразделение:</label>
              <select type="text" name="Subdivision" id="Sub_division" required>
                	<option value="">Выберите цех</option>
      <option value="Цех1">Цех 2</option>
                	<option value="Цех2">Цех 2</option>
              </select>
            </p>
            <p>
              <label for="Name_TU">Наименование:</label>
              <input type="text" name="NameTU" id="Name_TU">
            </p>
            <p>
              <label for="Signing_Date">Дата подписания:</label>
              <input type="date" name="SigningDate" id="Signing_Date">
            </p>
            <p>
              <label for="Validity_Date">Срок действия до:</label>
              <input type="date" name="Validity" id="Validity_Date">
            </p>
            <p>
             <label for="File_URL">Выбрать файл приказа:</label>
        <input type="file" name="file" id="File_URL" required>
      	    </p>
            <input type="submit" value="Отправить">
          <input type="hidden" value="" name="recaptchaResponse"></form>
</body>
</html>


JS code
jQuery(document).ready(function() {
    jQuery('#otpravka').submit(function(event){
      event.preventDefault();
      let fd = new FormData(this);
        jQuery.ajax({
        url: jQuery(this).attr('action'),
        type: jQuery(this).attr('method'),
        data: fd,
        cache: false,
        contentType: false,
        processData: false,
        success: function(data){
        console.log('succes');
        alert('Данные отправлены');
        console.log(data);
        jQuery('#otpravka')[0].reset();
        },
      });
 	});
});


PHP
<?php
 $files_dir = 'files/';
if(isset($_FILES["file"])){ 
    if(is_uploaded_file($_FILES["file"]["tmp_name"])){
        move_uploaded_file($_FILES["file"]["tmp_name"], $files_dir.$_FILES["file"]["name"]);
    // Тут выводим ссылку
$linkDL = $files_dir.$_FILES["file"]["name"];}}
/* Попытка подключения к серверу MySQL. Предполагая, что вы используете MySQL
 сервер с настройкой по умолчанию (пользователь root без пароля) */
$link = mysqli_connect("localhost", "root", "", "wordpress");
 
// Проверьте подключение
if($link === false){
    die("ERROR: Нет подключения. " . mysqli_connect_error());
}
 
//  экранирует специальные символы в строке
$Subdivision = mysqli_real_escape_string($link, $_REQUEST['Subdivision']);
$NameTU = mysqli_real_escape_string($link, $_REQUEST['NameTU']);
$SigningDate = mysqli_real_escape_string($link, $_REQUEST['SigningDate']);
$Validity = mysqli_real_escape_string($link, $_REQUEST['Validity']);
$linkDownload = $linkDL;
 
// Попытка выполнения запроса вставки
$sql = "INSERT INTO wp_tceha (Subdivision, NameTU, SigningDate, Validity, FileURL) VALUES ('$Subdivision',  '$NameTU', '$SigningDate', '$Validity', '$linkDownload')";
if(mysqli_query($link, $sql)){
    echo "Записи успешно добавлены.";
} else{
    echo "ERROR: Не удалось выполнить $sql. " . mysqli_error($link);
}
 
// Закрыть соединение
mysqli_close($link);
?>


And thanks in advance)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2022-03-29
@SilenceOfWinter

because none of us knows how to use linux

there is nothing special to be able to do there - most distributions have a simple installation, instructions for installing an http server with php and mysql take half a page at most (the settings are about the same) + a bunch of ready-made assemblies.
https://digitalocean.com/community/tutorials/how-t...
files are loaded on it at a speed of 1 Mbps, when the speed is 100 Mbps from the provider.

100 Mbit. This is most likely the speed of the network, not the Internet. Usually, providers have a upload speed much lower than the download speed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question