You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Matias Hernandez Arellano <ms...@archlinux.cl> on 2011/04/26 23:51:15 UTC

use thrift to create an interface from ruby to C++ and use it as webservice

(Sorry for my english)
Hi!, this is my first attempt to use Thrift, i arrive from a stackoverflow answer.

First i tell about the idea/problem next the question.

I have an application created with C++ that takes an image and make some processing with this, then return a result. This have to be donde with C++ for performance purpose. The application run with OpenCV, armadillo and FANN, the return value can be True or False (1 or 0).

The idea is to have an application running on a mobile device (or any other device) and take a picture and send to a server where the C++ application take it, process and return a response. The mobile device have to able to send the image and wait for the response to take and action.

The first idea was create a webservice to expose the C++ functionality, i thought about rails, but i can't find a way to solve this problem, so finally i found Thrift.

The question.

It's possible to use Thrift for this?

My idea:

Create a Server written in C++ to run the processing application (create this server with Thrift).

And create, with thrift, the code to use this server, and use this code to make a implementation in the mobile device.

The application is for my thesis for Computer Science.

Thanks in advance.


--
Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl





RE: use thrift to create an interface from ruby to C++ and use it as webservice

Posted by Mark Slee <ms...@fb.com>.
Exactly, things like that. A lot of thrift fields also have encodings for sizes. So a malformed request might make the server think, "I am about to receive a string that is 5429823549082 bytes in length," or "I am about to receive a list of 1M elements."

Many of our protocol implementations already allow you to set limits on sizes of things to prevent these particular issues, but they are generally not things that have been deeply vetted.

By comparison, most open web-server implementations are full of loads of code that sets limits on request sizes, memory use, malformed inputs, connection lifetimes, timeouts, request time, etc. It really is quite a long list of considerations. All things that certainly can be made robust in Thrift, but no one's done a deep audit... so, caveat emptor.

Cheers,
Mark

-----Original Message-----
From: Richard Salz [mailto:rsalz@us.ibm.com] 
Sent: Tuesday, April 26, 2011 6:13 PM
To: user@thrift.apache.org
Subject: Re: use thrift to create an interface from ruby to C++ and use it as webservice

Alex <al...@gmail.com> wrote on 04/26/2011 08:44:22 PM:

> What is it about them that makes it unsuitable for public use? I am
> currently running a Thrift server (Ruby) in a production environment
> for remote clients.

First, note that Mark was referring to the C++ servers, not Ruby. But that 
doesn't mean the Ruby stuff is "safe" either. It could be; nobody's making 
any comment on it.

In general, there is a huge amount of work involved in moving a server 
from a friendly behind-a-firewall environment, where clients make mistakes 
but aren't malicious, and putting that code into the Internet, where there 
are enough malicious folks out there to cause you trouble.

For example, suppose someone open a TCP connection and then lets it sit 
idle, or sends a byte every five seconds.  How many of those clients do 
you need before your server becomes unavailable, perhaps costing you 
revenue?

And so on. :(

        /r$

--
STSM, WebSphere Appliance Architect
https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/



Re: use thrift to create an interface from ruby to C++ and use it as webservice

Posted by Richard Salz <rs...@us.ibm.com>.
Alex <al...@gmail.com> wrote on 04/26/2011 08:44:22 PM:

> What is it about them that makes it unsuitable for public use? I am
> currently running a Thrift server (Ruby) in a production environment
> for remote clients.

First, note that Mark was referring to the C++ servers, not Ruby. But that 
doesn't mean the Ruby stuff is "safe" either. It could be; nobody's making 
any comment on it.

In general, there is a huge amount of work involved in moving a server 
from a friendly behind-a-firewall environment, where clients make mistakes 
but aren't malicious, and putting that code into the Internet, where there 
are enough malicious folks out there to cause you trouble.

For example, suppose someone open a TCP connection and then lets it sit 
idle, or sends a byte every five seconds.  How many of those clients do 
you need before your server becomes unavailable, perhaps costing you 
revenue?

And so on. :(

        /r$

--
STSM, WebSphere Appliance Architect
https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/



Re: use thrift to create an interface from ruby to C++ and use it as webservice

Posted by Alex <al...@gmail.com>.
On Tue, 26 Apr 2011 22:17:01 +0000
Mark Slee <ms...@fb.com> wrote:

> It's worth noting that the C++ servers we have for Thrift are not
> really designed to be used on the open internet. They tend to assume
> that you are in a protected intranet environment, behind a firewall.

What is it about them that makes it unsuitable for public use? I am
currently running a Thrift server (Ruby) in a production environment
for remote clients.

-- 
Alex

RE: use thrift to create an interface from ruby to C++ and use it as webservice

Posted by Mark Slee <ms...@fb.com>.
It's open source, you can just cite the code!

Other than that, I suppose there's just the whitepaper. I wouldn't think a citation is really necessary for this sort of application, but feel free.

-----Original Message-----
From: Matias Hernandez Arellano [mailto:msdark@archlinux.cl] 
Sent: Tuesday, April 26, 2011 4:46 PM
To: user@thrift.apache.org
Subject: Re: use thrift to create an interface from ruby to C++ and use it as webservice

Thanks for your time!!!...

I will try this idea... 

Thanks again...

and i let you know...

Ah!!! .. is there any document to include (like a citation) in my thesis document? or just the whitepaper?
El 26-04-2011, a las 18:17, Mark Slee escribió:

> This is certainly doable with Thrift.
> 
> Technically, it won't be a "web" service, as Thrift doesn't offer and off-the-shelf C++ HTTP server implementation. You would have to embed Thrift in another server if you want HTTP.
> 
> It's worth noting that the C++ servers we have for Thrift are not really designed to be used on the open internet. They tend to assume that you are in a protected intranet environment, behind a firewall. If this is just for a thesis project and not something you realistically need to worry about being defended against potentially malicious internet traffic, Thrift should be able to get you off the ground running very quickly.
> 
> Cheers,
> mcslee
> 
> -----Original Message-----
> From: Matias Hernandez Arellano [mailto:msdark@archlinux.cl] 
> Sent: Tuesday, April 26, 2011 2:51 PM
> To: user@thrift.apache.org
> Subject: use thrift to create an interface from ruby to C++ and use it as webservice
> 
> (Sorry for my english)
> Hi!, this is my first attempt to use Thrift, i arrive from a stackoverflow answer.
> 
> First i tell about the idea/problem next the question.
> 
> I have an application created with C++ that takes an image and make some processing with this, then return a result. This have to be donde with C++ for performance purpose. The application run with OpenCV, armadillo and FANN, the return value can be True or False (1 or 0).
> 
> The idea is to have an application running on a mobile device (or any other device) and take a picture and send to a server where the C++ application take it, process and return a response. The mobile device have to able to send the image and wait for the response to take and action.
> 
> The first idea was create a webservice to expose the C++ functionality, i thought about rails, but i can't find a way to solve this problem, so finally i found Thrift.
> 
> The question.
> 
> It's possible to use Thrift for this?
> 
> My idea:
> 
> Create a Server written in C++ to run the processing application (create this server with Thrift).
> 
> And create, with thrift, the code to use this server, and use this code to make a implementation in the mobile device.
> 
> The application is for my thesis for Computer Science.
> 
> Thanks in advance.
> 
> 
> --
> Matías Hernandez Arellano
> Ingeniero de Software/Proyectos en VisionLabs S.A
> CDA Archlinux-CL
> www.msdark.archlinux.cl
> 
> 
> 
> 

Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl





Re: use thrift to create an interface from ruby to C++ and use it as webservice

Posted by Matias Hernandez Arellano <ms...@archlinux.cl>.
Thanks for your time!!!...

I will try this idea... 

Thanks again...

and i let you know...

Ah!!! .. is there any document to include (like a citation) in my thesis document? or just the whitepaper?
El 26-04-2011, a las 18:17, Mark Slee escribió:

> This is certainly doable with Thrift.
> 
> Technically, it won't be a "web" service, as Thrift doesn't offer and off-the-shelf C++ HTTP server implementation. You would have to embed Thrift in another server if you want HTTP.
> 
> It's worth noting that the C++ servers we have for Thrift are not really designed to be used on the open internet. They tend to assume that you are in a protected intranet environment, behind a firewall. If this is just for a thesis project and not something you realistically need to worry about being defended against potentially malicious internet traffic, Thrift should be able to get you off the ground running very quickly.
> 
> Cheers,
> mcslee
> 
> -----Original Message-----
> From: Matias Hernandez Arellano [mailto:msdark@archlinux.cl] 
> Sent: Tuesday, April 26, 2011 2:51 PM
> To: user@thrift.apache.org
> Subject: use thrift to create an interface from ruby to C++ and use it as webservice
> 
> (Sorry for my english)
> Hi!, this is my first attempt to use Thrift, i arrive from a stackoverflow answer.
> 
> First i tell about the idea/problem next the question.
> 
> I have an application created with C++ that takes an image and make some processing with this, then return a result. This have to be donde with C++ for performance purpose. The application run with OpenCV, armadillo and FANN, the return value can be True or False (1 or 0).
> 
> The idea is to have an application running on a mobile device (or any other device) and take a picture and send to a server where the C++ application take it, process and return a response. The mobile device have to able to send the image and wait for the response to take and action.
> 
> The first idea was create a webservice to expose the C++ functionality, i thought about rails, but i can't find a way to solve this problem, so finally i found Thrift.
> 
> The question.
> 
> It's possible to use Thrift for this?
> 
> My idea:
> 
> Create a Server written in C++ to run the processing application (create this server with Thrift).
> 
> And create, with thrift, the code to use this server, and use this code to make a implementation in the mobile device.
> 
> The application is for my thesis for Computer Science.
> 
> Thanks in advance.
> 
> 
> --
> Matías Hernandez Arellano
> Ingeniero de Software/Proyectos en VisionLabs S.A
> CDA Archlinux-CL
> www.msdark.archlinux.cl
> 
> 
> 
> 

Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl





RE: use thrift to create an interface from ruby to C++ and use it as webservice

Posted by Mark Slee <ms...@fb.com>.
That should work fine, though it'll require you to write a bit more plumbing code for passing the image and file data around. Assuming the ruby/php webserver just takes care of this for you (which most of them do), it's probably not a bad approach.

Thrift will make communicating between the ruby/php web process and a C++ server very easy.

-----Original Message-----
From: Matias Hernandez Arellano [mailto:msdark@archlinux.cl] 
Sent: Tuesday, April 26, 2011 4:36 PM
To: user@thrift.apache.org
Subject: Re: use thrift to create an interface from ruby to C++ and use it as webservice

Thanks for your response...

So, i get another idea: create a php/ruby interface to use the GET http method to specify the image that need to upload .. (http://myserver.dom/upload.php?file=/dir/to/image/image.jpeg i know this is not secure but this will work i guess) and this interface communicate with the C++ application (a thrift server) to make the calculations and then send a response to the device ...


Am i right?? thrift can do the communication between a web client and C++ so i think this won't be a problem (the idea)..

Thanks a lot for your time.


El 26-04-2011, a las 18:17, Mark Slee escribió:

> This is certainly doable with Thrift.
> 
> Technically, it won't be a "web" service, as Thrift doesn't offer and off-the-shelf C++ HTTP server implementation. You would have to embed Thrift in another server if you want HTTP.
> 
> It's worth noting that the C++ servers we have for Thrift are not really designed to be used on the open internet. They tend to assume that you are in a protected intranet environment, behind a firewall. If this is just for a thesis project and not something you realistically need to worry about being defended against potentially malicious internet traffic, Thrift should be able to get you off the ground running very quickly.
> 
> Cheers,
> mcslee
> 
> -----Original Message-----
> From: Matias Hernandez Arellano [mailto:msdark@archlinux.cl] 
> Sent: Tuesday, April 26, 2011 2:51 PM
> To: user@thrift.apache.org
> Subject: use thrift to create an interface from ruby to C++ and use it as webservice
> 
> (Sorry for my english)
> Hi!, this is my first attempt to use Thrift, i arrive from a stackoverflow answer.
> 
> First i tell about the idea/problem next the question.
> 
> I have an application created with C++ that takes an image and make some processing with this, then return a result. This have to be donde with C++ for performance purpose. The application run with OpenCV, armadillo and FANN, the return value can be True or False (1 or 0).
> 
> The idea is to have an application running on a mobile device (or any other device) and take a picture and send to a server where the C++ application take it, process and return a response. The mobile device have to able to send the image and wait for the response to take and action.
> 
> The first idea was create a webservice to expose the C++ functionality, i thought about rails, but i can't find a way to solve this problem, so finally i found Thrift.
> 
> The question.
> 
> It's possible to use Thrift for this?
> 
> My idea:
> 
> Create a Server written in C++ to run the processing application (create this server with Thrift).
> 
> And create, with thrift, the code to use this server, and use this code to make a implementation in the mobile device.
> 
> The application is for my thesis for Computer Science.
> 
> Thanks in advance.
> 
> 
> --
> Matías Hernandez Arellano
> Ingeniero de Software/Proyectos en VisionLabs S.A
> CDA Archlinux-CL
> www.msdark.archlinux.cl
> 
> 
> 
> 

Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl





Re: use thrift to create an interface from ruby to C++ and use it as webservice

Posted by Matias Hernandez Arellano <ms...@archlinux.cl>.
Thanks for your response...

So, i get another idea: create a php/ruby interface to use the GET http method to specify the image that need to upload .. (http://myserver.dom/upload.php?file=/dir/to/image/image.jpeg i know this is not secure but this will work i guess) and this interface communicate with the C++ application (a thrift server) to make the calculations and then send a response to the device ...


Am i right?? thrift can do the communication between a web client and C++ so i think this won't be a problem (the idea)..

Thanks a lot for your time.


El 26-04-2011, a las 18:17, Mark Slee escribió:

> This is certainly doable with Thrift.
> 
> Technically, it won't be a "web" service, as Thrift doesn't offer and off-the-shelf C++ HTTP server implementation. You would have to embed Thrift in another server if you want HTTP.
> 
> It's worth noting that the C++ servers we have for Thrift are not really designed to be used on the open internet. They tend to assume that you are in a protected intranet environment, behind a firewall. If this is just for a thesis project and not something you realistically need to worry about being defended against potentially malicious internet traffic, Thrift should be able to get you off the ground running very quickly.
> 
> Cheers,
> mcslee
> 
> -----Original Message-----
> From: Matias Hernandez Arellano [mailto:msdark@archlinux.cl] 
> Sent: Tuesday, April 26, 2011 2:51 PM
> To: user@thrift.apache.org
> Subject: use thrift to create an interface from ruby to C++ and use it as webservice
> 
> (Sorry for my english)
> Hi!, this is my first attempt to use Thrift, i arrive from a stackoverflow answer.
> 
> First i tell about the idea/problem next the question.
> 
> I have an application created with C++ that takes an image and make some processing with this, then return a result. This have to be donde with C++ for performance purpose. The application run with OpenCV, armadillo and FANN, the return value can be True or False (1 or 0).
> 
> The idea is to have an application running on a mobile device (or any other device) and take a picture and send to a server where the C++ application take it, process and return a response. The mobile device have to able to send the image and wait for the response to take and action.
> 
> The first idea was create a webservice to expose the C++ functionality, i thought about rails, but i can't find a way to solve this problem, so finally i found Thrift.
> 
> The question.
> 
> It's possible to use Thrift for this?
> 
> My idea:
> 
> Create a Server written in C++ to run the processing application (create this server with Thrift).
> 
> And create, with thrift, the code to use this server, and use this code to make a implementation in the mobile device.
> 
> The application is for my thesis for Computer Science.
> 
> Thanks in advance.
> 
> 
> --
> Matías Hernandez Arellano
> Ingeniero de Software/Proyectos en VisionLabs S.A
> CDA Archlinux-CL
> www.msdark.archlinux.cl
> 
> 
> 
> 

Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl





RE: use thrift to create an interface from ruby to C++ and use it as webservice

Posted by Mark Slee <ms...@fb.com>.
This is certainly doable with Thrift.

Technically, it won't be a "web" service, as Thrift doesn't offer and off-the-shelf C++ HTTP server implementation. You would have to embed Thrift in another server if you want HTTP.

It's worth noting that the C++ servers we have for Thrift are not really designed to be used on the open internet. They tend to assume that you are in a protected intranet environment, behind a firewall. If this is just for a thesis project and not something you realistically need to worry about being defended against potentially malicious internet traffic, Thrift should be able to get you off the ground running very quickly.

Cheers,
mcslee

-----Original Message-----
From: Matias Hernandez Arellano [mailto:msdark@archlinux.cl] 
Sent: Tuesday, April 26, 2011 2:51 PM
To: user@thrift.apache.org
Subject: use thrift to create an interface from ruby to C++ and use it as webservice

(Sorry for my english)
Hi!, this is my first attempt to use Thrift, i arrive from a stackoverflow answer.

First i tell about the idea/problem next the question.

I have an application created with C++ that takes an image and make some processing with this, then return a result. This have to be donde with C++ for performance purpose. The application run with OpenCV, armadillo and FANN, the return value can be True or False (1 or 0).

The idea is to have an application running on a mobile device (or any other device) and take a picture and send to a server where the C++ application take it, process and return a response. The mobile device have to able to send the image and wait for the response to take and action.

The first idea was create a webservice to expose the C++ functionality, i thought about rails, but i can't find a way to solve this problem, so finally i found Thrift.

The question.

It's possible to use Thrift for this?

My idea:

Create a Server written in C++ to run the processing application (create this server with Thrift).

And create, with thrift, the code to use this server, and use this code to make a implementation in the mobile device.

The application is for my thesis for Computer Science.

Thanks in advance.


--
Matías Hernandez Arellano
Ingeniero de Software/Proyectos en VisionLabs S.A
CDA Archlinux-CL
www.msdark.archlinux.cl