dpd3982 2013-05-20 20:08
浏览 37

添加缩略图如何减慢我的网站的速度?

When I add 15 thumbnails(4kb-5kb each) my website tends to slow down a lot or even crashes on 2.5k users online, and without them it can take up to 4.5k-5k.

I made a script that will make thumbnail from animated gif on every image upload and store the path of that image in the database. On every page open before adding the thumbnail my website would deliver from database url, title, id and path to the gif image, only thing that changed is the getting the path of the thumbnail for 15 titles.

My website is http://www.smesniposteri.com/ on the right you can see 15 title I was talking about. Here is the code regarding pages users open each visit with and without thumbnail.

Without:

$sql = "SELECT id, url, hits, subject FROM ".DB_PREFIX."items WHERE `id` != '".$id."' AND `type` = '".$cat."' ORDER BY `timestamp` DESC LIMIT 0, 15;


$result = $db->query($sql);
$template->assign_vars('others_row', array(
'URL'   => $url."/".create_item_url($row['id'], $row['subject'], $cat),
'HITS'  => number_format($row['hits'], 0, ',', '.'),
'SUBJECT'   => $row['subject']
    ));

with thumbnail:

$sql = "SELECT id, url, hits, subject, thumb_url FROM ".DB_PREFIX."items WHERE `id` !=   '".$id."' AND `type` = '".$cat."' ORDER BY `timestamp` DESC LIMIT 0, 15;


$result = $db->query($sql);
$template->assign_vars('others_row', array(
'URL'   => $url."/".create_item_url($row['id'], $row['subject'], $cat),
'HITS'  => number_format($row['hits'], 0, ',', '.'),
'THUMBNAIL'   => $row['thumb_url'],
'SUBJECT'   => $row['subject']
    ));
  • 写回答

1条回答 默认 最新

  • douxie0824 2013-05-20 20:19
    关注

    A lot of things could be going on here. Most likely, I would say that when you have that many varied images, and that many users, its an issue with hard drive thrashing. If your database and images are on the same drive, requesting 15 different filesystem files several thousand times a second on top of database seeks would cause some delay. Especially if the images are on a fragmented hard drive. Really, you need to run some performance tools like Perfmon, and observe cpu, memory, and drive metrics while running your server with images and without. Also check database query execution plans when running in both modes to make sure your code isn't making a mass of database calls you aren't expecting. That should tell you where your bottle neck is.

    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用