ProxyPass and the P Option

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
35 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: ProxyPass and the P Option

Richard Eng
I guess I can do something like this:

<VirtualHost 192.168.1.101:443>
RewriteEngine       on
ProxyRequests       off
ProxyPreserveHost   on
SSLEngine           on
SSLCertificateFile  /etc/apache2/ssl/apache.pem
DocumentRoot        /var/www/ssl
ProxyPass           /seaside/go  balancer://seaside_cluster
stickysession=MYCOOKIE  nofailover=on
ProxyPassReverse    /seaside/go  balancer://seaside_cluster
<Proxy balancer://seaside_cluster>
    BalancerMember  http://localhost:9090/seaside/go  route=A_
    BalancerMember  http://localhost:9091/seaside/go  route=B_
    BalancerMember  http://localhost:9092/seaside/go  route=C_
</Proxy>
RewriteRule  ^/$  balancer://seaside_cluster [P,L]
</VirtualHost>


Apparently, the format of the cookie name is something like
'somename.someroute'. I think in the above example, somename would be
MYCOOKIE and someroute would be A_ or B_ or C_. Am I understanding
correctly?

But do I need to setup cookies in Seaside? If so, do I need to setup the
cookie name format, as well? If so, how?

Thanks,
Richard

--------
How do you ensure session affinity?

It looks like you are using a round-robin strategy. I guess this is
what Apache does by default. You have to ensure that only the first
request goes to a random image, subsequent requests should go to the
same image.

Lukas


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ProxyPass and the P Option

Boris Popov, DeepCove Labs (SNN)
In reply to this post by Richard Eng
Re: [Seaside] ProxyPass and the P Option

Did you indicate to balancer how to determine sticky sessions? I think there's a setting for it.

Cheers!

-Boris
(Sent from a BlackBerry)

----- Original Message -----
From: [hidden email] <[hidden email]>
To: Seaside - general discussion <[hidden email]>
Sent: Tue Nov 06 04:36:02 2007
Subject: Re: [Seaside] ProxyPass and the P Option

As a matter of fact, Lukas, when I woke up this morning, I thought I should
gather some data. So I started tracking the Transcript. Here's what I found:

With ONE VM (9090) in the balancer cluster:

Initial page (typing http://www.goodsexnetwork.com)
/seaside/go/

Clicking on About Us
/seaside/go/?_k=LQeoPxhB&_s=GKpDhxmXUPTXvMES&5
/seaside/go/?_k=BeOXObFr&_s=GKpDhxmXUPTXvMES

Clicking on Services
/seaside/go/?_k=GcdAcWkd&_s=GKpDhxmXUPTXvMES&6
/seaside/go/?_k=ymJpsfHH&_s=GKpDhxmXUPTXvMES

Clicking on Registration/Login
/seaside/go/?_k=GBUIFPiq&_s=GKpDhxmXUPTXvMES&7
/seaside/go/?_k=FQErKPay&_s=GKpDhxmXUPTXvMES

Clicking on Contact Us
/seaside/go/?_k=LHOSwmFl&_s=GKpDhxmXUPTXvMES&9
/seaside/go/?_k=yqdTQvsk&_s=GKpDhxmXUPTXvMES

As you can see, the session number remains constant. My web app is working
perfectly!


With THREE VMs (9090, 9091, 9092):

Initial page
(9090)
/seaside/go/

Clicking on About Us
(9092)
/seaside/go/
(9091)
/seaside/go/?_k=HOPZQNPd&_s=AnxoaOgasUPcEfCp&5

Clicking on Services
(9091)
/seaside/go/
(9090)
/seaside/go/?_k=EWqdbkqZ&_s=LCdHsZYDEHKgRPJx&6

Clicking on Registration/Login
(9090)
/seaside/go/
(9092)
/seaside/go/?_k=MSKlyDVX&_s=IPsgzreQVBMvqmbr&7

Clicking on Contact Us
(9092)
/seaside/go/
(9091)
/seaside/go/?_k=dvMVcwbK&_s=EdWhWjDdMnBoRAPP&8

Clicking on About Us
(9091)
/seaside/go/
(9090)
/seaside/go/?_k=wscOnKIR&_s=YOTvBvZGLAwbxnlk&5


As you can see, what's happening when you have more than one VM in the
balancer cluster is that each time you click on a page, it starts a new
session! And in a different VM!

The succession of port numbers (9092/9091, 9091/9090, 9090/9092, 9092/9091,
9091/9090) suggests that the sessions are not sticky. The load balancer is
cycling through my VMs. But I'm the only user! I should only have one
session.

What is going on???

Regards,
Richard

-------
Did you observe access_log, error_log, rewrite_log, etc. of your
server? Did you consider adding some logging statements to the
Smalltalk web-server to see what comes in and what goes out?

Lukas


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ProxyPass and the P Option

Lukas Renggli
In reply to this post by Richard Eng
> The succession of port numbers (9092/9091, 9091/9090, 9090/9092, 9092/9091,
> 9091/9090) suggests that the sessions are not sticky. The load balancer is
> cycling through my VMs. But I'm the only user! I should only have one
> session.

How do you ensure session affinity?

It looks like you are using a round-robin strategy. I guess this is
what Apache does by default. You have to ensure that only the first
request goes to a random image, subsequent requests should go to the
same image.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ProxyPass and the P Option

Boris Popov, DeepCove Labs (SNN)
In reply to this post by Richard Eng
Re: [Seaside] ProxyPass and the P Option

You could add route identifying cookie to each app, say its hostname plus port number although I recall seeing solutions to use mod balancer without modding existing apps with mod_headers, google some.


Cheers!

-Boris
(Sent from a BlackBerry)

----- Original Message -----
From: [hidden email] <[hidden email]>
To: Seaside - general discussion <[hidden email]>
Sent: Tue Nov 06 06:28:51 2007
Subject: Re: [Seaside] ProxyPass and the P Option

I guess I can do something like this:

<VirtualHost 192.168.1.101:443>
RewriteEngine       on
ProxyRequests       off
ProxyPreserveHost   on
SSLEngine           on
SSLCertificateFile  /etc/apache2/ssl/apache.pem
DocumentRoot        /var/www/ssl
ProxyPass           /seaside/go  balancer://seaside_cluster
stickysession=MYCOOKIE  nofailover=on
ProxyPassReverse    /seaside/go  balancer://seaside_cluster
<Proxy balancer://seaside_cluster>
    BalancerMember  http://localhost:9090/seaside/go  route=A_
    BalancerMember  http://localhost:9091/seaside/go  route=B_
    BalancerMember  http://localhost:9092/seaside/go  route=C_
</Proxy>
RewriteRule  ^/$  balancer://seaside_cluster [P,L]
</VirtualHost>


Apparently, the format of the cookie name is something like
'somename.someroute'. I think in the above example, somename would be
MYCOOKIE and someroute would be A_ or B_ or C_. Am I understanding
correctly?

But do I need to setup cookies in Seaside? If so, do I need to setup the
cookie name format, as well? If so, how?

Thanks,
Richard

--------
How do you ensure session affinity?

It looks like you are using a round-robin strategy. I guess this is
what Apache does by default. You have to ensure that only the first
request goes to a random image, subsequent requests should go to the
same image.

Lukas


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ProxyPass and the P Option

Richard Eng
In reply to this post by Richard Eng
But isn't imageName1 the same as imageName2 ? In other words, imageName is a
constant, in my case, "GoodSexNetwork", since 'SmalltalkImage current
imageName' returns '/home/richard/seaside/GoodSexNetwork.image'.

I think the cookie needs to be made unique with, say, the port number. How
do you obtain the port number in Seaside?

Thanks,
Richard

------
Ramon wrote:

Have Seaside write out the image name in a cookie as the last step in your
initial request (making sure to grab any state you need first).

initialRequest: aRequest
    self parseAnyNeededParams: aRequest.

    (self session currentRequest cookieAt: #server)
        ifNil: [self session redirectWithCookie:
            (WACookie
                key: #server
                value: 'seaside.',
                    ((SmalltalkImage current imageName copyAfterLast:
                        FileDirectory slash asCharacter) copyUpToLast:
$.))].

And configure your cluster with the route=imageName

<Proxy balancer://seaside_cluster>
    BalancerMember  http://localhost:3001/seaside  route=imageName1
    BalancerMember  http://localhost:3002/seaside  route=imageName2
</Proxy>


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: ProxyPass and the P Option

Ramon Leon-5
In reply to this post by Richard Eng
> I guess I can do something like this:
>
> <VirtualHost 192.168.1.101:443>
> RewriteEngine       on
> ProxyRequests       off
> ProxyPreserveHost   on
> SSLEngine           on
> SSLCertificateFile  /etc/apache2/ssl/apache.pem
> DocumentRoot        /var/www/ssl
> ProxyPass           /seaside/go  balancer://seaside_cluster
> stickysession=MYCOOKIE  nofailover=on
> ProxyPassReverse    /seaside/go  balancer://seaside_cluster
> <Proxy balancer://seaside_cluster>
>     BalancerMember  http://localhost:9090/seaside/go  route=A_
>     BalancerMember  http://localhost:9091/seaside/go  route=B_
>     BalancerMember  http://localhost:9092/seaside/go 
> route=C_ </Proxy> RewriteRule  ^/$  
> balancer://seaside_cluster [P,L] </VirtualHost>
>
>
> Apparently, the format of the cookie name is something like
> 'somename.someroute'. I think in the above example, somename
> would be MYCOOKIE and someroute would be A_ or B_ or C_. Am I
> understanding correctly?
>
> But do I need to setup cookies in Seaside? If so, do I need
> to setup the cookie name format, as well? If so, how?
>
> Thanks,
> Richard

Have Seaside write out the image name in a cookie as the last step in your
initial request (making sure to grab any state you need first).

initialRequest: aRequest
    self parseAnyNeededParams: aRequest.

    (self session currentRequest cookieAt: #server)
        ifNil: [self session redirectWithCookie:
            (WACookie
                key: #server
                value: 'seaside.',
                    ((SmalltalkImage current imageName copyAfterLast:
                        FileDirectory slash asCharacter) copyUpToLast:
$.))].

And configure your cluster with the route=imageName

<Proxy balancer://seaside_cluster>
    BalancerMember  http://localhost:3001/seaside  route=imageName1
    BalancerMember  http://localhost:3002/seaside  route=imageName2
</Proxy>

ProxyPass /seaside/files balancer://seaside_cluster/files
lbmethod=byrequests stickysession=server
ProxyPass / balancer://seaside_cluster/ lbmethod=byrequests
stickysession=server
ProxyPassReverse / balancer://seaside_cluster/

Tell Apache what the cookie name is and it will have what it needs to parse
the cookie and route to the correct image.  I couldn't get this working last
time I tried but I was missing the information about the "." Apache was
expecting in the cookie, I chose HAProxy instead.  Now that this works, I
might have to switch back to Apache for load balancing, very nice!  Found
what I needed in
http://www.markround.com/archives/33-Apache-mod_proxy-balancing-with-PHP-sti
cky-sessions.html

Ramon Leon
http://onsmalltalk.com 

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: ProxyPass and the P Option

Boris Popov, DeepCove Labs (SNN)
In reply to this post by Richard Eng
You'd need to ask your webserver, for instance Swazoo,

SwazooServer singleton servers collect: [:ea | ea port]

Set (7777)

Cheers,

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any
attachments.

Thank you.

> -----Original Message-----
> From: [hidden email] [mailto:seaside-
> [hidden email]] On Behalf Of Richard Eng
> Sent: Tuesday, November 06, 2007 9:13 AM
> To: Seaside - general discussion
> Subject: Re: [Seaside] ProxyPass and the P Option
>
> But isn't imageName1 the same as imageName2 ? In other words,
imageName is
> a
> constant, in my case, "GoodSexNetwork", since 'SmalltalkImage current
> imageName' returns '/home/richard/seaside/GoodSexNetwork.image'.
>
> I think the cookie needs to be made unique with, say, the port number.
How
> do you obtain the port number in Seaside?
>
> Thanks,
> Richard
>
> ------
> Ramon wrote:
>
> Have Seaside write out the image name in a cookie as the last step in
your

> initial request (making sure to grab any state you need first).
>
> initialRequest: aRequest
>     self parseAnyNeededParams: aRequest.
>
>     (self session currentRequest cookieAt: #server)
>         ifNil: [self session redirectWithCookie:
>             (WACookie
>                 key: #server
>                 value: 'seaside.',
>                     ((SmalltalkImage current imageName copyAfterLast:
>                         FileDirectory slash asCharacter) copyUpToLast:
> $.))].
>
> And configure your cluster with the route=imageName
>
> <Proxy balancer://seaside_cluster>
>     BalancerMember  http://localhost:3001/seaside  route=imageName1
>     BalancerMember  http://localhost:3002/seaside  route=imageName2
> </Proxy>
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: ProxyPass and the P Option

Ramon Leon-5
In reply to this post by Richard Eng
> But isn't imageName1 the same as imageName2 ? In other words,
> imageName is a constant, in my case, "GoodSexNetwork", since
> 'SmalltalkImage current imageName' returns
> '/home/richard/seaside/GoodSexNetwork.image'.
>
> I think the cookie needs to be made unique with, say, the
> port number. How do you obtain the port number in Seaside?
>
> Thanks,
> Richard

Depends on how you start multiple images, multiple copies of the same image
with a switch to ignore the lock on the changes file or just launch multiple
images which are all copies of a master each with their own changes file. I
was lazy and chose the latter because it was easier to just create a few
copies and launch them all manually in windows when testing this.  You could
use anything unique, the port I guess would do it as well.  If you're only
running one server, this will get what you want..

((HttpService allInstances
        select: [:each | each isRunning])
                collect:[:each | each portNumber]) first

Ramon Leon
http://onsmalltalk.com

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re:ProxyPass and the P Option

Richard Eng
In reply to this post by Richard Eng
Re: #cookieAt:

There is no such message in Seaside 2.7/Squeak 3.9. Is this new to Seaside
2.8 ?

I'm having difficulty locating any similar cookie-related messages for 'self
session currentRequest'.

Thanks,
Richard

------
Ramon wrote:

    (self session currentRequest cookieAt: #server)
        ifNil: [self session redirectWithCookie:
            (WACookie
                key: #server
                value: 'seaside.',


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: ProxyPass and the P Option

Ramon Leon-5
> Re: #cookieAt:
>
> There is no such message in Seaside 2.7/Squeak 3.9. Is this
> new to Seaside
> 2.8 ?
>
> I'm having difficulty locating any similar cookie-related
> messages for 'self session currentRequest'.
>
> Thanks,
> Richard

self session currentRequest cookies at: #server

in 2.7, #cookieAt: is just a shortcut.  Just look at the WARequest class,
you'll see what's available.

Ramon Leon
http://onsmalltalk.com 

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ProxyPass and the P Option

Richard Eng
In reply to this post by Richard Eng
Instead of

    self session currentRequest cookies at: #server

I had to do

    self session currentRequest cookies at: #server ifAbsent:

because #at: throws a ³key not found² exception.


Thank you very much, Ramon! You rock!

My web app is essentially complete now. Our website is SSL-secured. My app
is load-balanced. Once I work out some streaming video issues, I'll be able
to deploy our 1U rack server (to be colocated at a host provider).

Then we can start our beta test program in the New Year. With any luck, our
website will go live next summer. I started this Seaside project in June and
within one year I expect to go live. *One year!!* Let's see a Java/Struts or
PHP or C#/ASP.NET developer accomplish that!

Regards,
Richard


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: ProxyPass and the P Option

Boris Popov, DeepCove Labs (SNN)
That would of course depend on what the application actually does, I bet one could deploy /counter application rather quickly ;)

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message
header. Unless otherwise indicated, it contains information that is
private and confidential. If you have received it in error, please
notify the sender and delete the entire message including any
attachments.

Thank you.

> -----Original Message-----
> From: [hidden email] [mailto:seaside-
> [hidden email]] On Behalf Of Richard Eng
> Sent: Tuesday, November 06, 2007 3:58 PM
> To: Seaside - general discussion
> Subject: Re: [Seaside] ProxyPass and the P Option
>
> Instead of
>
>     self session currentRequest cookies at: #server
>
> I had to do
>
>     self session currentRequest cookies at: #server ifAbsent:
>
> because #at: throws a ³key not found² exception.
>
>
> Thank you very much, Ramon! You rock!
>
> My web app is essentially complete now. Our website is SSL-secured. My app
> is load-balanced. Once I work out some streaming video issues, I'll be
> able
> to deploy our 1U rack server (to be colocated at a host provider).
>
> Then we can start our beta test program in the New Year. With any luck,
> our
> website will go live next summer. I started this Seaside project in June
> and
> within one year I expect to go live. *One year!!* Let's see a Java/Struts
> or
> PHP or C#/ASP.NET developer accomplish that!
>
> Regards,
> Richard
>
>
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: ProxyPass and the P Option

Ramon Leon-5
In reply to this post by Richard Eng
> Thank you very much, Ramon! You rock!
>
> My web app is essentially complete now. Our website is
> SSL-secured. My app is load-balanced. Once I work out some
> streaming video issues, I'll be able to deploy our 1U rack
> server (to be colocated at a host provider).
>
> Then we can start our beta test program in the New Year. With
> any luck, our website will go live next summer. I started
> this Seaside project in June and within one year I expect to
> go live. *One year!!* Let's see a Java/Struts or PHP or
> C#/ASP.NET developer accomplish that!
>
> Regards,
> Richard

No problem and congratulations, once you launch be sure to let Lukas know
and get yourself listed on the seaside.st/users page.  If you have the time,
start a blog and write about your experiences so others can learn more about
Seaside.

Ramon Leon
http://onsmalltalk.com 

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: ProxyPass and the P Option

Richard Eng
In reply to this post by Richard Eng
http://open-sourcerer.blogspot.com/

Hey, it's a start.

Richard


--------

> Thank you very much, Ramon! You rock!
>
> My web app is essentially complete now. Our website is
> SSL-secured. My app is load-balanced. Once I work out some
> streaming video issues, I'll be able to deploy our 1U rack
> server (to be colocated at a host provider).
>
> Then we can start our beta test program in the New Year. With
> any luck, our website will go live next summer. I started
> this Seaside project in June and within one year I expect to
> go live. *One year!!* Let's see a Java/Struts or PHP or
> C#/ASP.NET developer accomplish that!
>
> Regards,
> Richard

No problem and congratulations, once you launch be sure to let Lukas know
and get yourself listed on the seaside.st/users page.  If you have the time,
start a blog and write about your experiences so others can learn more about
Seaside.

Ramon Leon


_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: ProxyPass and the P Option

Ramon Leon-5
> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf
> Of Richard Eng
> Sent: Friday, November 09, 2007 7:16 AM
> To: Seaside - general discussion
> Subject: Re: [Seaside] ProxyPass and the P Option
>
> http://open-sourcerer.blogspot.com/
>
> Hey, it's a start.
>
> Richard

Awesome, I just subscribed to you feed, I hope you keep it up.  Retired
already... I'm jealous!

Ramon Leon
http://onsmalltalk.com 

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
12