473,770 Members | 7,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Intense CPU strain....sugge stions

I am writing YAPSS (Yet Another Photo Sharing Site).

Currently, the user can upload up to six pictures at once. When the
uploads are complete, I then have a script that will resize the pix to
different thumbnails for speed. However, imagine resizing 6 pictures
of 2300x2200 pixels in 6 different sizes (maintaining the best quality
I can) on a Pentium 3 450Mhz running Ubuntu and 384 megs of ram.

Seriously.

Obviously, this is a test server and the real deal will be more
powerful but I don't want my users sitting around waiting on
resizing. I would prefer to add the pictures to a queue for later
processing and allow the users to go do other things on the site.

My question is, how would you recommend I kick off this script and
allow the user to browse away? I've heard people suggest using an
iframe but that sounds kludgey. I've also considered using some type
of local XML-RPC server/client and have a script make a call. But
would the client then have to sit and wait for a response?

As you can see, I am on the planning stages at this point.

I do like the idea of having a server running waiting to accept resize-
requests. That way, he could easily be moved to dedicated hardware
later on.

Thoughts/opinions welcomed!

Thanks!

cbmeeks
http://www.signaldev.com

May 30 '07 #1
6 1537
Message-ID: <11************ **********@m36g 2000hse.googleg roups.comfrom
cbmeeks contained the following:
>Currently, the user can upload up to six pictures at once. When the
uploads are complete, I then have a script that will resize the pix to
different thumbnails for speed. However, imagine resizing 6 pictures
of 2300x2200 pixels in 6 different sizes (maintaining the best quality
I can) on a Pentium 3 450Mhz running Ubuntu and 384 megs of ram.

Seriously.
Why not just upload the pics and leave resizing til the pics are fetched
for the first time? After that fetch from the filesystem.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
May 30 '07 #2
I thought about that. The problem is, that I want to allow very high
res uploads. If the user uploaded 20 pictures, and they went to a
gallery page for the first time, it would take a while to resize.
That could leave a bad first impression.

On May 30, 7:41 pm, Geoff Berrow <blthe...@ckdog .co.ukwrote:
Message-ID: <11************ **********@m36g 2000hse.googleg roups.comfrom
cbmeeks contained the following:
Currently, the user can upload up to six pictures at once. When the
uploads are complete, I then have a script that will resize the pix to
different thumbnails for speed. However, imagine resizing 6 pictures
of 2300x2200 pixels in 6 different sizes (maintaining the best quality
I can) on a Pentium 3 450Mhz running Ubuntu and 384 megs of ram.
Seriously.

Why not just upload the pics and leave resizing til the pics are fetched
for the first time? After that fetch from the filesystem.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDshttp://www.ckdog.co.uk/rfdmaker/

May 31 '07 #3
cbmeeks wrote:
I thought about that. The problem is, that I want to allow very high
res uploads. If the user uploaded 20 pictures, and they went to a
gallery page for the first time, it would take a while to resize.
That could leave a bad first impression.

On May 30, 7:41 pm, Geoff Berrow <blthe...@ckdog .co.ukwrote:
>Message-ID: <11************ **********@m36g 2000hse.googleg roups.comfrom
cbmeeks contained the following:
>>Currently, the user can upload up to six pictures at once. When the
uploads are complete, I then have a script that will resize the pix to
different thumbnails for speed. However, imagine resizing 6 pictures
of 2300x2200 pixels in 6 different sizes (maintaining the best quality
I can) on a Pentium 3 450Mhz running Ubuntu and 384 megs of ram.
Seriously.
Why not just upload the pics and leave resizing til the pics are fetched
for the first time? After that fetch from the filesystem.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDshttp://www.ckdog.co.uk/rfdmaker/

Well, you could kick off a batch job to do your resizing, then return to
the user. That way it can keep processing the images. The only thing
you'll have to handle is when the user wants to display his gallery
before it's ready.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
May 31 '07 #4
Well, you could kick off a batch job to do your resizing, then return to
the user. That way it can keep processing the images. The only thing
you'll have to handle is when the user wants to display his gallery
before it's ready.

That's exactly how I want to do it. I just don't know the best way to
execute it. I like the idea of having an XML-RPC server running but I
am concerned with security (as I should be).

So, let's say I have the following code (using CI):

....
$this->Upload->do_uploads() ; // handle the actual uploading.

$this->Photos->do_resizing( ); // handle the resizing

redirect('waiti ng');
.....

"Waiting" doesn't get kicked off until after do_resizing (sorry, new
to PHP). I'm sure there is a smarter way. I'd like to avoid pop-ups,
iframes, javascript, etc if possible.

I also thought about having the "do_resizin g" simple add some records
to a db and have a program running on the server full time that checks
the db frequently. But wouldn't that be wasteful? I like the idea of
programs laying dormant until something kicks it in the pants and says
"do something!" lol

Thanks

cbmeeks
http://www.signaldev.com


May 31 '07 #5
cbmeeks wrote:
>Well, you could kick off a batch job to do your resizing, then return to
the user. That way it can keep processing the images. The only thing
you'll have to handle is when the user wants to display his gallery
before it's ready.


That's exactly how I want to do it. I just don't know the best way to
execute it. I like the idea of having an XML-RPC server running but I
am concerned with security (as I should be).

So, let's say I have the following code (using CI):

...
$this->Upload->do_uploads() ; // handle the actual uploading.

$this->Photos->do_resizing( ); // handle the resizing

redirect('waiti ng');
....

"Waiting" doesn't get kicked off until after do_resizing (sorry, new
to PHP). I'm sure there is a smarter way. I'd like to avoid pop-ups,
iframes, javascript, etc if possible.

I also thought about having the "do_resizin g" simple add some records
to a db and have a program running on the server full time that checks
the db frequently. But wouldn't that be wasteful? I like the idea of
programs laying dormant until something kicks it in the pants and says
"do something!" lol

Thanks

cbmeeks
http://www.signaldev.com

First of all, the redirect won't happen until the code reaches there -
which is after your resizing. So that's normal operation.

You could have a cron job kicked off every few minutes to resize the
pictures, but again, you'll run into the problem that after uploading
the user won't be able to see the pictures he's just uploaded - at least
in various sizes.

You could use shell_exec() to start off a background process, i.e.
(assuming Unix/Linux):

shell_exec('noh up myprog file1 file2 file3 2/dev/null &');

nohup says to execute a command without hangups and no output, 2>
/dev/null throws away any error messages, and the '&' at the end says
run in the background.

You'll still run into a problem that the resizing might not occur as
fast as the user wants to display it; you'll have to be able to handle
this in your display routines.

Alternatively, you could do something like:

<body>
echo 'Resizing your images, please wait...<br>';
flush();
$this->Upload->do_uploads() ; // handle the actual uploading.
$this->Photos->do_resizing( ); // handle the resizing
echo 'Done!. <a href="nextpage. php">Click here to continue</a>';
</body>

The flush() works with most browsers if you keep the html simple - it
forces the output to the browser and the browser displays it. But if
you start to get fancy (i.e. tables, etc.), many browsers will wait for
the end of the element to actually display.

The only problem with this is, once you've sent *any* output to the
browser, you can't redirect them to another page via php (you could use
an html redirect). That's why the link.

Just some ideas.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
May 31 '07 #6
Thanks for the ideas!

I think I might have a somewhat complex system that might work.

First of all, when pictures are uploaded, I record the information in
the db. I could add a column that says "is_ready" so that they
wouldn't show in the galleries and the resize could mark them ready.

I'm really leaning towards and XML-RPC system. The XML-RPC server
could sit and wait for requests. The client ("do_upload" ) could send
a request when uploading is finished. That should take just a second
or so...hopefully.

The request could contain information on what to resize.

The XML-RPC server then could instruct the resize script to run and
then the script could mark the image ready.

I would need to make sure I knew how to run a robust XML-RPC server
capable of handling many requests.

I know this whole system seems complicated but I am trying to think
scalability. The XML-RPC server could easily be moved to any machine.

Thanks for suggestions guys.

cbmeeks
http://www.signaldev.com

On May 31, 11:40 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
cbmeeks wrote:
Well, you could kick off a batch job to do your resizing, then return to
the user. That way it can keep processing the images. The only thing
you'll have to handle is when the user wants to display his gallery
before it's ready.
That's exactly how I want to do it. I just don't know the best way to
execute it. I like the idea of having an XML-RPC server running but I
am concerned with security (as I should be).
So, let's say I have the following code (using CI):
...
$this->Upload->do_uploads() ; // handle the actual uploading.
$this->Photos->do_resizing( ); // handle the resizing
redirect('waiti ng');
....
"Waiting" doesn't get kicked off until after do_resizing (sorry, new
to PHP). I'm sure there is a smarter way. I'd like to avoid pop-ups,
iframes, javascript, etc if possible.
I also thought about having the "do_resizin g" simple add some records
to a db and have a program running on the server full time that checks
the db frequently. But wouldn't that be wasteful? I like the idea of
programs laying dormant until something kicks it in the pants and says
"do something!" lol
Thanks
cbmeeks
http://www.signaldev.com

First of all, the redirect won't happen until the code reaches there -
which is after your resizing. So that's normal operation.

You could have a cron job kicked off every few minutes to resize the
pictures, but again, you'll run into the problem that after uploading
the user won't be able to see the pictures he's just uploaded - at least
in various sizes.

You could use shell_exec() to start off a background process, i.e.
(assuming Unix/Linux):

shell_exec('noh up myprog file1 file2 file3 2/dev/null &');

nohup says to execute a command without hangups and no output, 2>
/dev/null throws away any error messages, and the '&' at the end says
run in the background.

You'll still run into a problem that the resizing might not occur as
fast as the user wants to display it; you'll have to be able to handle
this in your display routines.

Alternatively, you could do something like:

<body>
echo 'Resizing your images, please wait...<br>';
flush();
$this->Upload->do_uploads() ; // handle the actual uploading.
$this->Photos->do_resizing( ); // handle the resizing
echo 'Done!. <a href="nextpage. php">Click here to continue</a>';
</body>

The flush() works with most browsers if you keep the html simple - it
forces the output to the browser and the browser displays it. But if
you start to get fancy (i.e. tables, etc.), many browsers will wait for
the end of the element to actually display.

The only problem with this is, once you've sent *any* output to the
browser, you can't redirect them to another page via php (you could use
an html redirect). That's why the link.

Just some ideas.

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===

May 31 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1286
by: Matt W | last post by:
Hi all, I'm planning to use MySQL's full-text search for my forum system (possibly 5+ million posts). I've been playing with it a lot lately to see the performance and functionality and have some suggestions/questions. First, since a few of you may be wanting to know, here is a thread where I was doing some speed/optimization tests and stuff with 3 million posts: http://www.sitepointforums.com/showthread.php?threadid=69555
10
1958
by: Ron Ruble | last post by:
I'd like to get suggestions from some of the folks here regarding tools and processes for a new, small development team. I'm starting a new job next week, and part of the fun is being able to start fresh. It's a bit different than what I've done in the past, in a smaller organization than I'm used to. Very small team; about 4 developers, 4 additional IT support
1
1349
by: Brian Basquille | last post by:
Hello all. Have been working on the Air Hockey game on and off for a couple of weeks now.. but have had plenty of other assignments to keep me busy along with it. But i would like some suggestions on improving it. It's far from fully working, but some suggestions on the following would be great. Please download it from: http://homepage.eircom.net/~basquilletj/AirHockey.rar.
62
2427
by: A.M. Kuchling | last post by:
Here are some thoughts on reorganizing Python's documentation, with one big suggestion. The tutorial seems to be in pretty good shape because Raymond Hettinger has been keeping it up to date. It doesn't cover everything, but it's a solid introduction, and if people don't find it works for them, they have lots of alternative books. No suggestions here. There are endless minor bugs in the library reference, but that seems
6
1416
by: iclinux | last post by:
I have to build a GUI applicaiton that could run on different OS such as windows and *nix, which GUI toolkit is better? Best Regards.
45
3461
by: Gregory Petrosyan | last post by:
1) From 2.4.2 documentation: There are two new valid (semantic) forms for the raise statement: raise Class, instance raise instance 2) In python: >>> raise NameError Traceback (most recent call last): File "<stdin>", line 1, in ? NameError
1
1312
by: stoprsi | last post by:
RSI Warrior 4.0 is an award-winning ergonomics software package helping thousands of computer users prevent and recover from computer-related Repetitive Strain Injuries such as carpal tunnel, tendonitis and deQuervain's syndromes. Features include: * Intelligent strain monitoring system.
0
1027
by: stoprsi | last post by:
RSI Warrior 4.0 is an award-winning ergonomics software package helping thousands of computer users prevent and recover from computer-related Repetitive Strain Injuries such as carpal tunnel, tendonitis and deQuervain's syndromes. Features include: * Intelligent strain monitoring system.
0
4493
rnd me
by: rnd me | last post by:
Purpose: Allows you to create "presets" for text form inputs. "Lightweight and simple to setup, it adds a lot of convenience for ~1kb of code." Only one function, two parameters: First argument is the element to upgrade. you can specify the input's name, id or the input itself. you can also pass an array containing of any of these to easily bind multiple fields to the same suggestions. Second argument is an array of suggestions.
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10058
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9870
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8886
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6678
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.