Server bully test

Well, not exactly crashed the server, but I stopped it from running which is a proof of concept.

With a simple Java program which sends legitimate requests from a legitimate device, the server failed after a few minutes. A quick manual restart over ssh got it up and running immediately.

public class BullyServerTest {
    
    public static BullyServerTest bst;

    public static void main(String[] args) {
        bst = new BullyServerTest();
    }
    
    boolean quit = false;
    
    private final String server_host = "SOMEWEBADDRESS"; // LOL
    private final int server_port = SOMESECRETNUMBER;
    
    private final String home = System.getProperty("user.home") + "/";
    
    public BullyServerTest() {
        Runtime.getRuntime().addShutdownHook(new Thread() {
            public void run() {
                quit = true;
                try { Thread.sleep(1000); } catch (InterruptedException ex) {}
            }
        });
        
        while (!quit) {
            try { Thread.sleep(randInt(10, 250)); } catch (InterruptedException ex) {}
            do_hello_world_bully();
        }
    }
    
    Random rand = new Random();
    
    private int randInt(int min, int max) {
        return rand.nextInt((max - min) + 1) + min;
    }
    
    private static final int COMMAND_HELLO = 1234;
    
    private void do_hello_world_bully() {
        int count = randInt(10, 100);
        System.out.println("HELLO WORLD BULLY at " + count + " times");
        
        while (count-- != 0) { // a shed load of threads at once
            new Thread(runnable_HW).start();
        }
        
        System.out.println("Completed...");
    }
    
    Runnable runnable_HW = new Runnable() {
        @Override
        public void run() {
            try {
                WLSocket socket = new WLSocket(server_host, server_port);

                socket.out.writeInt(COMMAND_HELLO);
                String hello = socket.in.readUTF();
                
            } catch (IOException ex) {
                System.out.println("Server failed with HELLO WORLD response");
            }
        }
    };
}

So the next step is to implement a thread pool so that the server will not hang on too many requests. It ran for less than a minute. The above program kept running until my 12Gb RAM ran out which was a bit longer. The current server does only have 4Gb RAM and couldn’t handle the amount of connections at once. I’ve also had to keep the sudden bandwidth usage down as I was hitting my upload and download limits.

Eventually the server and client code will all be rewritten in C++ and handle such things as low latency timeouts.

This has been a very interesting test. I’ll be leaving the hello world server command in for future testing to simulate fake requests.

Project updates

I’ve had the server running for over 3 weeks so far, and although it’s only a few testing devices, it’s looking very promising. The server hasn’t failed once and I’ve even ssh’d into it and run a couple of checks.

My next step, whilst I’m taking the time to build the database software, is to setup another server. More servers means backups and 100% running and up time. The servers can also update each other depending on the regions requirements. That means if I upload content that belongs on other servers, then the servers will organise themselves automatically. A bit like a decentralised distribution of data.

Devices will also receive updates when new servers have been added as periodically they will question what servers are available to them. This will help with manual load balancing as more devices are added. Although were I want to go with this will not need manual load balancing, it is something I want to test out on test servers anyway.

Although all of this is stuck in my head at the moment, I’ve had a few quick browses through my code base and it this seems pretty simply to implement and upgrade without any interruptions to the servers current up time. This is definitely something I want to fully test out. Even down to the servers possibly updating themselves when one has been updated. I will look into this as I’m more leaning towards manually accepting server updates for security.

After long thinking over the weekend I was building myself up to putting this project forward to someone as a partnership proposal. I got home from work today and decided that’s a no. For the time being, this is staying mine.

Updates 2018-Feb-21

My project:

I’ve been taking my time on this project for a damn good reason, I don’t want to rush things and end up making some serious mistakes with it.

There are a few, quite a few bits of code, that will need a rewrite, mainly in C++. This is mainly for future proofing.

I’m currently on stage 2 of this which involves 3 main sections.

The first section involves the database which I am currently working on in MS Access. I used to be an Access master, so I’m getting my hands dirty and learning it all over again. For the past few months I’ve looked for anything that came close to what MS Access can actually do and I’ve found nothing. MS Access is everything for creating a database application from scratch. VBA might be a tad awkward, but it is doing everything I need it for so far. I hope in the future it can also do TCP communications.

The second and third sections of this stage 2 are a lot more involved in prepping for the future. The second being done this next week if all goes well.

The final third of stage 2 will involve the website. I’m hoping that it will be handled by someone I know who is fully capable. This will include handling accounts and payments too. And I’ve been told that it can also handle invoicing.

After that, it’s is just going with the flow. I’m being very weary of contacts because I’ve been bitten before.

Me:

I’ve still got a good few months before the above starts to take shape, although some early testing will be done sooner than expected. Apart from that I’m doing okay with myself apart from slacking with my exercising.

This month has been hard for moving things forward because I lost a lost of money this month. I still get annoyed over that. I could do with a few more devices to put out into the field. And with the lack of testing, I’ve also held back on setting up the cloud server.

Programming has been ‘nicely’ minimal. I’ve mainly been running all my software and fixing bugs. I have been able to chill. Well ‘ish’…

And I’ll get back to a regular weight lifting routine again.

 

Just a few updates

Well, that’s January over. And it seemed to have shot by really quick too.

The first stage of my personal project is complete and has been running 100% for quite a while now. It’s now just testing out in the field that needs doing.

I’ve got everything running through a DNS server that routes back to my home PC, so no matter where devices are running they can easily connect to my home PC for communications over TCP. Eventually this will be running on a cloud service which I’ve been looking into lately, whether that be Google or AWS or something else, I don’t know yet.

All network traffic runs on two way encryption which was actually very easy to implement. At the moment it is not a very complex encryption because I do want to test for speed overheads with this. If I’m handling 1000 plus devices, ‘at the same time’, then I really don’t want the CPU burning the house down. I’ve a few more cryptographic algorithms I want to test out too, but they can wait for now.

Video creation has been non-existent since before Christmas because I’ve been focused on the programming of this project. Over the last two days I’ve loaded up Blender and although I can move things around easy enough, the old knack has gone again. I really like Blender, but when it comes to finishing something off that requires programming, then Blender has to wait just like most other things.

One thing I do need to start focusing on, and I started looking into this before Christmas, was a full accounting database. The only one from the past that I’m familiar with is MS Access, and trying to find one that works on Linux is still a pain. I’m planning on using Linux so MS will not do. So, when it comes to storing all financial records, invoicing, etc, it looks like I’ll have to write my own software. Shame really, I do like the awesomeness of MS Access. (Which I started using at work earlier today)

So, the next stage is to finalise the tests out in the field. To do this, I will take my demo devices to various places and see it running just nicely. The management software will also be tested out in the field too.

Once that stage has been proven successful over time, then it’s the setting up of the rest of the management of the project. This will include accounts, security, moderation, sustainability tests, reviews on scale-ability, moving to an initial cloud server, and more.

Up until this is a showcase-able project then for the most parts, apart from what I write about, this will be under wraps because I want this to be mine with the help of very few and limited resources. Trusting is hard to do when you lived through enough of life to have experienced people take away your ideas in a wink.

Until next time.