Monday, January 24, 2011

What is the best apache/linux config for this server?

2 x Intel Xeon-Woodcrest 5130-DualCore 2GB RAM Ubuntu 10.04.0-64

In the worst case this box will be serving ~300 people requesting ~700 images at the same time. The images are around 5K each.

I can upgrade or change the machine if anyone has any suggestions.

Thanks!

  • So its completely static content, it only serves up images? Maybe go with nginx or lighttpd rather than apache. You could probably throw some more ram in there, 2GB isn't heaps and ram is cheap. Serving static files will be limited by I/O more than anything tho, what kind of hard drives have you got in there? Also can you expand on what you mean by "300 people requesting 700 images at the same time"?

    In fact, if all you are doing is serving images, do you even need a dedicated server or could you run in on a CDN like S3? Is this an internal or external server?

    From micmcg
  • If you are only serving static content installing a reverse proxy like varnish will also greatly improve performance, although I would recommend adding a little more ram (another 2 or 4 GB) to the box.

    Also don't forget to make your webserver (for static content, nginx or lighttpd are good) add expire headers to the http responses, or the reverse proxy will not perform optimal.

    From Sarek

Implementing dry-run in bash scripts

How would one implement a dry-run option in a bash script?

I can think of either wrapping every single command in an if and echoing out the command instead of running it if the script is running with dry-run.

Another way would be to define a function and then passing each command call through that function.

Something like:

function _run () {
    if [[ "$DRY_RUN" ]]; then
        echo $@
    else
        $@
    fi
}

`_run mv /tmp/file /tmp/file2`

`DRY_RUN=true _run mv /tmp/file /tmp/file2`

Is this just wrong and there is a much better way of doing it?

  • See BashFAQ/050 for a discussion of this subject.

    Apikot : Not an alternative, but it looks like an excellent resource for testing and working with longer bash programs.
    Dennis Williamson : I rolled back the edit that added an anchor to a particular part of the linked page since the point of my answer, as stated, is to read the discussion as a whole rather than point to one specific how-to portion. The point of the linked page is generally to try to avoid putting commands to be executed into variables since there are a lot of gotchas.
  • I wanted to play with the answer from @Dennis Williamson's. Here's what I got:

    Run () {
        if [ "$TEST" ]; then
            echo "$*"
            return 0
        fi
    
        eval "$@"
    }
    

    The 'eval "$@"' is important here, and is better then simply doing $* like you did above. I forget why this is exactly (too tired), but I'll try to explain it when I'm less tired (Sorry!)

    $ mkdir dir
    $ touch dir/file1 dir/file2
    $ FOO="dir/*"
    $ TEST=true Run ls -l $FOO
    ls -l dir/file1 dir/file2
    $ Run ls -l $FOO
    -rw-r--r--  1 stefanl  stefanl  0 Jun  2 21:06 dir/file1
    -rw-r--r--  1 stefanl  stefanl  0 Jun  2 21:06 dir/file2
    

VPS showing low disk space despite there is nothing major on it

Hello experts,

On my VPS server I was trying to see the used disk space and when I open My Computer it shows 17.9 GB free out of 39.8 GB it means that 21.9 GB space is used.

However, when I select all files and folders from C: and try to see the total size, it just count approximately 11 GB. The difference is around 10 GB. Where is this 10 GB going if I have not stored anything else here?

I asked above question from my VPS provider and he responded below

Check hidden files/system files/etc. This is default windows OS and its utilization and not specific to setup. If you want specifics of usage, you can go ahead and get in touch with Microsoft support team and they'll provide you with exact specification of the same.

I am sure that Windows OS must not be taking up 10 GB space for hidden files and folders. My VPS has Windows Server 2008 R2 installed.

Can anyone help me in this on who is right?

  • Check and see if you have shadow copies configured. Shadow copies allow you to restore previous versions of files in a NTFS file system. Shadow copies don't show up in the normal file structure, but are taking disk space. Normally the default is that the shadow copies won't take more than 20% of the disk.

    From Knox

Why do I not see w3wp.exe processes from IIS6?

I have two Windows 2003 x64 R2 IIS boxes that are ostensibly setup the same way.

But for whatever reason, one of them has a W3WP.exe process for each application pool and the other one does not.

What could be the reason?

  • Can you verify if all the applications/Web Sites on the other server is accessed as well. w3wp.exe process won't be created unless the application is accessed. Probably the first server is taking all the requests and no requests are handled by the other server.

    Try browsing iisstart.htm page which is there in Default Web Site and you should see a w3wp.exe process created.

    AngryHacker : Ahh, you are right. It simply went to sleep.
    From Vivek

How to run python web pages with Apache?

Currently our web server is LAMP based,

but I need to install trac, which is written by python,

how can Apache support python requests?

How do I remotely enable the firewall on Server 2008 to exclude specific IP addresses?

Previously I was working with Server 2003 and managed to lock myself out of the server (I was accessing it remotely) by enabling the firewall.

I want to remotely enable the firewall on Server 2008 without locking myself out of the server (access via RDP) and then selectively add IP addresses to the firewall to exclude. i.e. block specific IP addresses.

Are there any step by step instructions on how to safely do this?

  • Best bet is to script it, with a scripted reversal should you be locked out.

    Say, if prompt is not answered in 20s, revert all settings.

    You can script the windows firewall using vbs or netsh commands.

    http://www.activexperts.com/activmonitor/windowsmanagement/scripts/networking/windowsfirewall/

    Scripting is good, it makes you think carefully about what you are planning to do.

    From Grizly
  • If you have a windows AD server you create a group policy and apply it to that OU that the windows server is in then enable the firewall but allow tcp port 3389 through the advanced firewall configuration. If you lock yourself out you can then just remove the GP or change it to turn off the firewall.

    Guy : It's not an AD server but thanks for the idea.
    From JohnyV