bullen
Posts: 283
Joined: Sun Apr 28, 2013 2:52 pm

Lightweight Java HTTP Async Server

Sun Apr 28, 2013 2:58 pm

Try this server: rupy

It's faster and uses less memory, also it has HTTP hot-deploy that is seamless for uninterrupted multiuser development and unnoticeable live deployments = no downtime.

It uses NIO, so it scales and can do real time comet long-poll chat and streaming!

Finally when you finished your app there's really cheap rpi cluster hosting: host.rupy.se
Last edited by bullen on Fri May 29, 2015 8:00 am, edited 6 times in total.
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

bullen
Posts: 283
Joined: Sun Apr 28, 2013 2:52 pm

Re: Lightweight Java HTTP app server

Sun Jun 09, 2013 10:18 pm

Just released version 1.0
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

bullen
Posts: 283
Joined: Sun Apr 28, 2013 2:52 pm

Re: Lightweight Java HTTP app server

Tue Nov 25, 2014 10:26 am

Now you can build your own HTTP server cluster on many RPi's with this. It also has a cluster NoSQL database!

We have a cheap PaaS ready for deployment, but you can easily build your own too!
Last edited by bullen on Fri Mar 13, 2015 9:51 am, edited 1 time in total.
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

auron89
Posts: 31
Joined: Fri Oct 31, 2014 11:54 am
Location: Rome

Re: Lightweight Java HTTP app server

Tue Nov 25, 2014 2:00 pm

how can I install on raspberry and make a deploy?

bullen
Posts: 283
Joined: Sun Apr 28, 2013 2:52 pm

Re: Lightweight Java HTTP app server

Tue Dec 23, 2014 7:17 pm

Tutorial, if you have a problem I can answer your specific question.
Last edited by bullen on Sun Mar 15, 2015 9:33 pm, edited 1 time in total.
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

User avatar
clicky
Posts: 413
Joined: Thu Oct 25, 2012 7:34 am

Re: Lightweight Java HTTP app server

Thu Dec 25, 2014 1:08 pm

I was a bit sceptical but it really seems very light and with small footprint. I'll try to use it for my next project (instead of built in server).

bullen
Posts: 283
Joined: Sun Apr 28, 2013 2:52 pm

Re: Lightweight Java HTTP app server

Sun Feb 08, 2015 10:24 am

Did a benchmark of the rupy cometstream and 6x it is. Almost the same performance as an old atom or a new NUC, but per watt it dominates!

Comet Stream

6.500 messages per joule!!! That might just be some kind of world record! ;)

Edit: I'm just blown away by this figure. The next best per watt is the Intel NUC, which costs 500$ (including memory and SSD) compared to the RPi2 which costs 45$ including SD card. So the RPi2 costs 1000% less to buy and 700% less to power for 70% of the performance. I was about to retire my RPi plans for an all Intel setup, but now I will use one passively cooled Intel NUC as loadbalancer for a cluster of RPi2 per node.
Last edited by bullen on Sun Mar 15, 2015 9:34 pm, edited 2 times in total.
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

bullen
Posts: 283
Joined: Sun Apr 28, 2013 2:52 pm

Re: Lightweight Java HTTP app server

Sat Feb 14, 2015 10:52 am

Now I have added so that you can hot-deploy to your pi with rupy on projects that use a COM port integration to increase development speed of all your Java hardware projects.

Install RXTX on your pi:

sudo apt-get install librxtx-java

Example code:

Code: Select all

public class Router extends Daemon.Com {
	static Daemon daemon;
	static Router router;
	
	private static InputStream in;
	private static OutputStream out;
	
	public Router(String tty) {
		try {
			System.setProperty("gnu.io.rxtx.SerialPorts", tty);
			CommPortIdentifier id = CommPortIdentifier.getPortIdentifier(tty);

			if(id.isCurrentlyOwned()) {
				System.out.println("Error: Port is currently in use.");
			} else {
				CommPort port = id.open("COM", 1000);

				if(port instanceof SerialPort) {
					SerialPort serial = (SerialPort) port;
					serial.setSerialPortParams(9600, 
							SerialPort.DATABITS_8, 
							SerialPort.STOPBITS_1, 
							SerialPort.PARITY_NONE);

					in = serial.getInputStream();
					out = serial.getOutputStream();
					
					Thread thread = new Thread(new Reader(in));
					thread.start();
				}
				else {
					System.out.println("Error: Only serial ports are handled by this example.");
				}
			}
		}
		catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	public static class Send extends Service {
		Receiver rec;
		
		public String path() { return "/"; }

		public void create(Daemon daemon) {
			rec = new Receiver(daemon);
			daemon.com().set(rec);
		}
		
		public void filter(Event event) throws Event, Exception {
			System.out.println(event.query().header());
			
			if(event.query().method() == Query.POST) {
				event.query().parse();
				String message = event.query().string("message");
				event.daemon().com().write(message.getBytes());
			}
		}
	}

	public static class Receiver implements Daemon.Listen {
		StringBuilder builder = new StringBuilder();
		
		Daemon daemon;
		
		public Receiver(Daemon daemon) {
			this.daemon = daemon;
		}
		
		public void read(byte[] data, int length) throws Exception {
			String in = new String(data, 0, length);
			
			System.out.println(in);
		}
	}
	
	public void write(byte[] data) throws IOException {
		out.write(data);
	}
	
	public static class Reader implements Runnable {
		InputStream in;

		public Reader(InputStream in) {
			this.in = in;
		}

		public void run() {
			byte[] data = new byte[1024];
			int length = -1;
			try {
				while((length = this.in.read(data)) > -1) {
					try {
						router.listen.read(data, length);
					}
					catch(Exception e) {
						e.printStackTrace();
					}
				}
			} catch(Exception e) {
				e.printStackTrace();
			}
		}
	}
	
	public static void main(String[] args) {
		daemon = Daemon.init(args);
		router = new Router("/dev/ttyAMA0");
		daemon.set(router);
		daemon.start();
	}
}
Then you need to add the hot-deployed jar to the classpath and run Router instead of Daemon:

java -Djava.library.path=/usr/lib/jni -classpath /usr/share/java/RXTXcomm.jar:http.jar:app/your-app.jar Router -pass XXXXXX
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

bullen
Posts: 283
Joined: Sun Apr 28, 2013 2:52 pm

Re: Lightweight Java HTTP Async Server

Fri May 29, 2015 8:03 am

Now the RPi 2 cluster is online on host.rupy.se:

Image

http://monitor.rupy.se

Here you can insert database entries across the entire cluster: http://root.rupy.se
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

bullen
Posts: 283
Joined: Sun Apr 28, 2013 2:52 pm

Re: Lightweight Java HTTP Async Server

Sun Mar 27, 2016 6:50 pm

Now I have built a multiplayer engine on top of this:

https://github.com/tinspin/fuse

Has both Javascript HTML5 and Unity C# clients!

Also I built a forum module:

http://binarytask.com
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

Return to “Java”