Concurrency in framework

19 views
Skip to first unread message

Manav Kedia

unread,
Jun 27, 2014, 11:56:51 AM6/27/14
to eiffel-web...@googlegroups.com
Hi,

I am creating a web server with the Eiffel Web Framework. I want the server to be able to handle multiple concurrent requests from clients. But I haven't been able to do that. If the server has to compute something, it stalls and the other clients can't connect to it or do anything else which the server is calculating. Is there a way to make the server concurrent, so that every client request gets its own thread or something, and it remains responsive ?

Thanks
Manav

Colin Adams

unread,
Jun 27, 2014, 12:00:39 PM6/27/14
to eiffel-web...@googlegroups.com
The answer probably depends upon the connector, but I suspect the answer is no (for most connectors). Which is a deficiency.

What you CAN do with Apache, mod_fcgid, and the FASTCGI connector (at least), is have Apache do load-balancing, by starting and stopping multiple copies of your server, dynamically. This is controlled by the Apache configuration parameters (see the docs for mod_fcgid).


--
--
You received this message because you are subscribed to the Google
Groups "Eiffel Web Framework" group.
 
To post to this group, send email to
eiffel-web...@googlegroups.com
To unsubscribe from this group, send email to
eiffel-web-frame...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/eiffel-web-framework
 
See the site for the Eiffel-Web-Framework project at
https://github.com/EiffelWebFramework/EWF
---
You received this message because you are subscribed to the Google Groups "Eiffel Web Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to eiffel-web-frame...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Manav Kedia

unread,
Jun 27, 2014, 12:03:34 PM6/27/14
to eiffel-web...@googlegroups.com
I am using Nino web server. Can Nino handle concurrency?


You received this message because you are subscribed to a topic in the Google Groups "Eiffel Web Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/eiffel-web-framework/jvSFBVXMmU0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to eiffel-web-frame...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Manav Kedia
Undergraduate Sophomore Student
Department of Computer Science and Engineering
IIT Kharagpur

Colin Adams

unread,
Jun 27, 2014, 12:05:15 PM6/27/14
to eiffel-web...@googlegroups.com
No it can't, as I understand.

Manav Kedia

unread,
Jun 27, 2014, 12:06:13 PM6/27/14
to eiffel-web...@googlegroups.com
Okay thanks alot :)

Manav Kedia

unread,
Jun 27, 2014, 12:23:55 PM6/27/14
to eiffel-web...@googlegroups.com
Hi,

I was thinking if maybe I could use callbacks? Say, the server takes 1 minute to do some calculation for a client and I send the response in the callback of that calculation. So, the server is still free to take new requests from other clients. 
Can I do it this way, I mean like if I have many callbacks running, and many responses being computed, will the nino server be able to map the appropriate response and requests?

Thanks
Manav

Colin Adams

unread,
Jun 27, 2014, 12:29:43 PM6/27/14
to eiffel-web...@googlegroups.com
No.
But if you design your web application protocol, you could do it.

So you determine that creating the response is going to take a long time. You then respond 303 See other, forking a thread to do the calculation. The Location header contains a one-off URL. You include a proprietary header to suggest how long to wait. The client then retries the request using the suggested location, after waiting for the suggested time.

Hm. A bit clunky.


--

javier hector

unread,
Jun 27, 2014, 1:05:30 PM6/27/14
to eiffel-web...@googlegroups.com
Hi, at he moment Nino Connector can't handle concurreny, but we have a Concurrent Nino in progress.

/Javier

Jocelyn Fiat

unread,
Jun 27, 2014, 4:33:24 PM6/27/14
to eiffel-web-framework
Ok I guess, we have to integrate the concurrent nino soon as Javier mentioned.
Since this is requested for time to time.
But yes for now, we recommend to use libfcgi with apache for instance.
Then apache is managing the load balancing and multi-process

-- Jocelyn
Jocelyn
------------------------------------------------------------------------
Eiffel Software
805-685-1006
http://www.eiffel.com
Customer support: http://support.eiffel.com
User group: http://groups.eiffel.com/join
------------------------------------------------------------------------

Manav Kedia

unread,
Jun 27, 2014, 5:23:53 PM6/27/14
to eiffel-web...@googlegroups.com
Thank you.


You received this message because you are subscribed to a topic in the Google Groups "Eiffel Web Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/eiffel-web-framework/jvSFBVXMmU0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to eiffel-web-frame...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Berend de Boer

unread,
Jun 27, 2014, 6:28:02 PM6/27/14
to eiffel-web...@googlegroups.com
>>>>> "Manav" == Manav Kedia <manavke...@gmail.com> writes:

Manav> I am creating a web server with the Eiffel Web Framework. I
Manav> want the server to be able to handle multiple concurrent
Manav> requests from clients. But I haven't been able to do
Manav> that. If the server has to compute something, it stalls and
Manav> the other clients can't connect to it or do anything else
Manav> which the server is calculating. Is there a way to make the
Manav> server concurrent, so that every client request gets its
Manav> own thread or something, and it remains responsive ?

Hi Manav,

I'm using a server in production that does this, but I'm using eposix
and can therefore fork. So it's a classical Unix fork model.

--
All the best,

Berend de Boer

Manav Kedia

unread,
Jun 30, 2014, 4:57:18 AM6/30/14
to eiffel-web...@googlegroups.com
Hi,

I tried to switch to libfcgi connector, but when I run it, its giving me the following error: 
The program can't start because libfcgi.dll is missing from your computer. Try reinstalling the program to fix this problem.

Thanks
​Manav

Jocelyn Fiat

unread,
Jun 30, 2014, 5:00:47 AM6/30/14
to eiffel-web-framework
Hi Manav Kedia,

When using the libfcgi connector, it has to be started by apache or IIS (I guess you are on Windows), and you need to have the libfcgi.dll file in the path of the server, or simpler, in the same folder of your EWF executable.


-- Jocelyn


--

Manav Kedia

unread,
Jun 30, 2014, 5:13:16 AM6/30/14
to eiffel-web...@googlegroups.com
Yes Jocelyn, I'm using it on Windows. I'm sorry I don't know much about apache. How do I start it from apache, and where do I find the libfcgi.dll file ?

Thanks


You received this message because you are subscribed to a topic in the Google Groups "Eiffel Web Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/eiffel-web-framework/jvSFBVXMmU0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to eiffel-web-frame...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

javier hector

unread,
Jun 30, 2014, 9:04:43 AM6/30/14
to eiffel-web...@googlegroups.com
Hi Manav, 
Please check the attached file to deploy an EWF app using Apache. 

Hope this helps. 

By the way, do you have a git repo to take a look at your server?

/Javier

EWFDeployment.pdf

Manav Kedia

unread,
Jun 30, 2014, 9:12:07 AM6/30/14
to eiffel-web...@googlegroups.com
Hi Javier,

Thanks for the slide. I have installed apache and got it running. 
But I can't find libfcgi.dll file to run the finalized version with libfcgi connector.


Thanks

Jocelyn Fiat

unread,
Jun 30, 2014, 9:26:50 AM6/30/14
to eiffel-web-framework
You should find the 32bits and 64bits version of libfcgi in the EWF repository

-- Jocelyn

Manav Kedia

unread,
Jun 30, 2014, 9:45:17 AM6/30/14
to eiffel-web...@googlegroups.com
I put the .dll in the same location as the final executable. But, its giving the following message, and the app is closing.

Status: 405 Method Not Allowed
Allow: GET
Content-Type: text/html
Content-Length: 1386

<html lang="en"><head><title>/Error 405 (Method Not Allowed)!!</title>
<style type="text/css">
div#header {color: #fff; background-color: #000; padding: 20px; text-align: cent
er; font-size: 2em; font-weight: bold;}
div#message { margin: 40px; text-align: center; font-size: 1.5em; }
div#suggestions { margin: auto; width: 60%;}
div#suggestions ul { }
div#footer {color: #999; background-color: #eee; padding: 10px; text-align: cent
er; }
div#logo { float: right; margin: 20px; width: 60px height: auto; font-size: 0.8e
m; text-align: center; }
div#logo div.outter { padding: 6px; width: 60px; border: solid 3px #500; backgro
und-color: #b00;}
div#logo div.outter div.inner1 { display: block; margin: 10px 15px;  width: 30px
; height: 50px; color: #fff; background-color: #fff; border: solid 2px #900; }
div#logo div.outter div.inner2 { margin: 10px 15px; width: 30px; height: 15px; c
olor: #fff; background-color: #fff; border: solid 2px #900; }
</style>
</head>
<body>
<div id="header">Error 405 (Method Not Allowed)!!</div><div id="logo"><div class
="outter"> <div class="inner1"></div><div class="inner2"></div></div>Error 405 (
Method Not Allowed)</div><div id="message">Error 405 (Method Not Allowed): the r
equest method <code></code> is inappropriate for the URL for <code>/</code>.</di
v><div id="suggestions"><strong>Allowed methods:</strong> GET
<div id="footer"></div></body>
</html>

Manav Kedia

unread,
Jun 30, 2014, 12:44:30 PM6/30/14
to eiffel-web...@googlegroups.com
Hi,

Even if you have a simple running application (with the directories and the settings) that uses libfcgi connector with EWF ( atleast one URI mapping), it will help me alot to understand where am I going wrong.

Thanks

Manav Kedia

unread,
Jul 1, 2014, 7:42:24 AM7/1/14
to eiffel-web...@googlegroups.com
Hi,

I got apache running and set up the fcgi script as given in the slides.
However, the error log says "Premature end of script headers: service.ews"

So, I tried to run my application using libfcgi connector in eiffelstudio itself by debugging it step by step.
I found that the feature 'process_fcgi_request' in WSF_LIBFCGI_CONNECTOR, is creating a request object with URL / and no request method(not even GET). This causes the server to call the feature execute_default from WSF_ROUTED_SERVICE and thus the server was giving the 405 error, even before I could send any client request to it.

Is this expected behaviour ( The request object with / and no request method) ? And how do I deal with it?

Or is it still a problem of configuring apache and has nothing to do with this / and blank request method .

Thanks 
Manav

Jocelyn Fiat

unread,
Jul 1, 2014, 8:34:06 AM7/1/14
to eiffel-web-framework
Hi Manav,

First it does not help to run libfcgi app in the debugger, indeed, apache is the one that start the libfcgi server (i.e your executable), and I think it opens pipe to communicate between apache and the various libfcgi server (this would need to be checked).
Anyway the debugger will not launch the libfcgi server as expected.

I will try to reproduce your issue on Windows+apache, and see what could be wrong.
Do you have the source code you are using somewhere? on github maybe?
This way, I could try to reproduce using your project.

-- Jocelyn

Manav Kedia

unread,
Jul 1, 2014, 8:43:24 AM7/1/14
to eiffel-web...@googlegroups.com
Hi Jocelyn,

Here is my code,
Thank you for trying to run it out. 

Jocelyn Fiat

unread,
Jul 1, 2014, 9:03:22 AM7/1/14
to eiffel-web-framework
Hi
I will try soon, but in the meantime a few more questions

Do you use the frozen, melted of finalized version of your executable?
In any case, I would advice to try with the finalized version for now.
Once you made it run correctly, you will see for melted or frozen version

Also make sure that your application don't have any print or io.put_string .. or similar that would be output to the console, I noticed in the past, that this may cause trouble with libfcgi.

Note that you can use for instance
res.put_error ("DEBUG" + req.request_uri + "%N")
And this will appear in the apache error logs file.


Side note: in github repository, you should avoid adding binary file, especially avoid to put the full EIFGENs, this makes the git repository big and the EIFGENs is useless for the source code.

-- Jocelyn



--

Manav Kedia

unread,
Jul 1, 2014, 9:19:39 AM7/1/14
to eiffel-web...@googlegroups.com
Hi

I used the finalized version. My application has a few  io.put_string. I'll remove then and try again.
Yes, I created that post this morning. 

Thanks


You received this message because you are subscribed to a topic in the Google Groups "Eiffel Web Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/eiffel-web-framework/jvSFBVXMmU0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to eiffel-web-frame...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Jocelyn Fiat

unread,
Jul 1, 2014, 9:21:43 AM7/1/14
to eiffel-web-framework
Ok, then let's try to figure out in this list what is your trouble, and you will be able to self-answer your question on stack-overflow.

Manav Kedia

unread,
Jul 1, 2014, 9:55:46 AM7/1/14
to eiffel-web...@googlegroups.com
Hi Jocelyn,

I tried what you said. And this is the result of my error.log file.

[Tue Jul 01 15:46:30 2014] [info] mod_fcgid: server 192.168.80.1:C:/Apache2.2/htdocs/app.exe(13820) started
[Tue Jul 01 15:46:30 2014] [error] [client 127.0.0.1] Premature end of script headers: service.ews
[Tue Jul 01 15:46:34 2014] [info] mod_fcgid: process C:/Apache2.2/htdocs/app.exe(13820) exit(normal exit), return code 2
[Tue Jul 01 15:46:34 2014] [warn] mod_fcgid: cleanup zombie process 13820
I just created a 'empty' service.ews file in the same location as the executable as given in the slide and a .htaccess file with the following code

Options +ExecCGI +Includes +FollowSymLinks -Indexes

<IfModule mod_fcgid.c>
AddHandler fcgid-script .ews
FcgidWrapper "C:/Apache2.2/htdocs/app.exe" .ews
</IfModule>

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ service.ews [L]
RewriteCond %{REQUEST_FILENAME} !­f
RewriteCond %{REQUEST_FILENAME} !­d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !service.ews
RewriteRule ^(.*)$ service.ews/$1
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
</IfModule>

And in the httpd.conf file, I loaded the 2 modules and changed AllowOverride All.

Am I missing something?

Jocelyn Fiat

unread,
Jul 1, 2014, 10:19:33 AM7/1/14
to eiffel-web-framework
I think that your apache configuration is ok.
It is probably an issue in your project ...

now I have cloned your git repository .. but it tooks some time since it is about 485.02MB
I will try to compile, test and reproduce your issue soon, probably tomorrow.

-- Jocelyn


Manav Kedia

unread,
Jul 1, 2014, 10:26:10 AM7/1/14
to eiffel-web...@googlegroups.com
Thank you.


You received this message because you are subscribed to a topic in the Google Groups "Eiffel Web Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/eiffel-web-framework/jvSFBVXMmU0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to eiffel-web-frame...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Manav Kedia

unread,
Jul 1, 2014, 10:27:38 AM7/1/14
to eiffel-web...@googlegroups.com
My project has absolute locations for the files to my Desktop where I was using it. I forgot to change and upload it. 

Jocelyn Fiat

unread,
Jul 1, 2014, 11:30:56 AM7/1/14
to eiffel-web-framework
Indeed I noticed it does not compile out of the box.
But I will figure out how to compile it.
In the meantime, you should try to run one of the EWF examples ... as libfcgi and see if this is working for you.
I think it will, if not, it will be much easier to find the issue from a simple app rather than a complex app that is not compiling out of the box.

-- Jocelyn

Colin Adams

unread,
Jul 1, 2014, 1:37:02 PM7/1/14
to eiffel-web...@googlegroups.com
I have experienced this.
If you try to debug before the parsing of the request is complete, this happens.
So try setting your breakpoint (I assume you use RT_DEBUGGER) AFTER the decoding of the request is complete (e.g. when your handler is first called).

Manav Kedia

unread,
Jul 2, 2014, 5:22:01 AM7/2/14
to eiffel-web...@googlegroups.com
Hi Jocelyn,

I had to make some changes in the .ecf file to compile with libfcgi target, and I had not updated the changes in the github account (I'm really sorry for that). I have uploaded the project in the github. Can you please clone it and try again. Also, I have added the following libraries to the $ISE_LIBRARY path in my computer : json(json-master), httpd, websocket_server. 
I have checked the version I uploaded on github and compiled the finalized version with libfcgi, so you should be able to compile now. 
Also, I have changed all the absolute paths, and removed the io.put_strings. You have to put www, projects, test_files in the same location as the executable and there should not be any path problems (I've tried running with nino and it works). 

Also, I tried to run the example https://github.com/EiffelWebFramework/ewf_examples/tree/master/app with libfcgi target like you said . I compiled the finalized version and put it in the same location as the executable and with the same apache code as before, its giving the same error. 

[Wed Jul 02 11:06:10 2014] [error] [client 127.0.0.1] Premature end of script headers: service.ews
[Wed Jul 02 11:06:18 2014] [info] mod_fcgid: process C:/Apache2.2/htdocs/app.exe(15948) exit(normal exit), return code 2

Thanks
Manav

Manav Kedia

unread,
Jul 2, 2014, 5:36:26 AM7/2/14
to eiffel-web...@googlegroups.com
Hi Colin,

I tried to do what you said. But if I just run the finalized version of libfcgi as a standalone application, it exits even before I am able to type and run localhost in my browser, and returns  405 Error in the console, saying that the request method is invalid( which is actually the case, because I tried to debug step by step and I saw that the server automatically creates a request object with / as URL and no request method, at startup).

PS (Jocelyn) : My github project is in the same location : https://github.com/kediamanav/Eiffel_Web_Server/tree/master/eve_server 

Jocelyn Fiat

unread,
Jul 2, 2014, 5:54:57 AM7/2/14
to eiffel-web-framework
Can you try to rename app.exe into app-libfcgi.exe for instance ?
and then with apache, update teh FcgidWrapper to

FcgidWrapper "C:/Apache2.2/htdocs/app-libfcgi.exe" .ews

I noticed that you used "gewf" to generate the initial EWF server, and I guess it was old version, anyway you should know a bit about some conventions for this "generated" code.

If you compile the target "app_any", the executable can be run as nino server, CGI or libfcgi server ...
If you look at the launcher code, you will see that it knows which connector to use at run-time based on the executable name. Check in your project APPLICATION.initialize_launcher_nature
  app-cgi or app-cgi.exe -> run as CGI app
  app-libfcgi or app-libfcgi.exe -> run as libfcgi server
  otherwise run as nino server.
In your case, this may be the issue, you are using "app.exe" ... so apache launch the app.exe , but the app.exe does not behave as a libfcgi server.

Now if you don't want this mess with executable filename, you should compile directly the target "app_libgcgi" which will generate an executable that will always run as a libfcgi server.

(for info, latest version of gewf , generate nicer code for the launcher, and for target *_any, the decision to use nino, cgi or libfcgi is based on extension, for instance  app.cgi, of app.fcgi ... but this is not currently your code).

So please, can you try either with targer app_libfcgi, or renaming your app.exe as app-libfcgi.exe ?
And let me know the result.

Otherwise, please contact me via Google Hangout, or skype, so that you don't waste more time on that.

-- Jocelyn



--

Manav Kedia

unread,
Jul 2, 2014, 6:19:51 AM7/2/14
to eiffel-web...@googlegroups.com
Hi Jocelyn,

I renamed it to app_libfcgi, and it worked !
Thank you for your help. 

Thank you Colin, Javier, Berend.

Jocelyn Fiat

unread,
Jul 2, 2014, 6:24:43 AM7/2/14
to eiffel-web-framework
Great,

If ever you clean your git repository and remove permanently the EIFGENs folders.
I can follow your progresses, and help for time to time if needed.

-- Jocelyn


--

Manav Kedia

unread,
Jul 2, 2014, 6:25:33 AM7/2/14
to eiffel-web...@googlegroups.com
I'll do that. Thanks :) 
You received this message because you are subscribed to a topic in the Google Groups "Eiffel Web Framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/eiffel-web-framework/jvSFBVXMmU0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to eiffel-web-frame...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
Reply all
Reply to author
Forward
0 new messages