Inter-Server Communication - django

I have an Django application which uses different Servers.
-> First I get request, I need to authenticate it to my Authentication Server
-> Dump the request data in Log Server
-> Process the Request and getting data from different Database Server
-> Respond to the Request
-> Dump the Response data to Log Server
Each of the Server (Authentication Server, Log server...) are basically Django Services.
What is the Best way to do this communication. Obviously HTTP Requests & Responses would take too long. Serving one Request would generate more than 5-6 new HTTP requests and responses.
Can I have any way (applicable to Django) to directly call a method of other server (say Authentication Server, Log Server)

Related

Is it possible to use django as a proxy for websoxket

I have a service (written in erlang) that accepts websocket connection from my django application. Django serves the page and the js script that makes the calls to the erlang service.
Now I want to go through the django server also for websocket connection and messaging. That is to use django as a proxy that forwards websocket connection and messages from the client to the Erlang service and sends back responses from the erlang service to the client. Optionally django should also check request authorization before forwarding them.
Is that possible?

SOAP request through JMeter with authentication

I'm having trouble sending a JMeter SOAP request through HTTP Request element -
Through SOAPUI I'm sending the request with the following properties:
Authentication via SOAP
But I cannot receive a valid response when I try to add these username password. I've tried to place it in HTTP Header Manager/ in HTTP Authorization Manager, but with no luck. I receive either error:
Response code: 404 Response message: Not Found
when placing this in the HTTP Authorization Manager and
HTTP Error 400. The request has an invalid header name
when placing the username and password in the header manager (with wss password type field, while in HTTP Authorization Manager there is not option like this).
What can I do to have a valid response from the server like I get in SOAPUI?
If you need to replicate SoapUI request I would suggest just to record the request from the SoapUI via JMeter HTTP(S) Test Script Recorder
In JMeter
File -> Template -> Recording -> Create
Workbench -> HTTP(S) Test Script Recorder -> Start
In SoapUI
File -> Preferences -> Proxy Settings
Host: localhost, Port: 8888
Enable proxy in SoapUI
Execute your request
Expand Thread Group -> Recording Controller in JMeter and observe the recorded request.
You may also need to correlate timestamps using __time() function check out Take the Pain out of Load Testing Secure Web Services for details on bypassing different web services security in JMeter tests.

Difference between a web-service and web-socket

As I mentioned in the title: I would like to know the difference between the web-service and the web-socket? when we used each one?
Thanks!
A web service is an HTTP server that responds to client SOAP/REST/JSON requests.
A web socket is a client-side API that allows a web browser to create a bidirectional communication link with a server without having to change/reload the current page. This is typically used for AJAX requests to dynamically update live content on the current page, or create chat sessions between clients, or implement custom protocols that run in the web browser.
Web services are based on HTTP protocol and use HTTP methods to relay data in a request and response paradigm. Thus the client will always be the one responsible for communicating with the server, requesting data and submitting data to the server i.e getting list of customers or products, adding products or customers to server.
In contrast, Web sockets allow bidirectional communication, meaning server can initiate communication as much as client can do the same. Typically you supply a host IP Address and port to the socket. Web sockets can be used to implement a chat application.
The key difference between Web sockets and Web services is that with web sockets you get bi-directional connection in which the server and client can continuously send messages back and forth while Web services are uni-directional connection concerned with supplying clients with resources

Server for Webservices

I am trying to develop webservices for a data collection server. I understand the restful services part of the schema, but what does the independent data collection server have to do differently to serve data to webservices? To be clear, "Data server - Webservices - third party client" is the overall schema. When a client requests data from webservices, how does it get it from the data server? HTTP request? Data server should send HTTP responses? Please explain.
You have 3 parties in the data exchange: Client, Web Service layer, and Data Server (Remote database). Generally speaking, the client would exchange the data by HTTP, or any other protocol. It is not strictly limited - but HTTP is the most frequent case. Next, you Web service layer would connect to the remote database. It all depends on your choice of technologies. Usually, you have specific classes to work with the remote databases such as JDBC Connection class for relational databases. When the client connects to your web service, the web service in turn calls the methods of classes, which connect to remote databases. How this happens is not the concern of the developer (it might be a binary protocol, or HTTP request - depends on the database) - you just have an API. When the response is returned to your classes, you transform it into some data format like XML, or JSON, and send it back to the client as an HTTP response, or with some other protocol.

How to add persistent connection support to a load-balanced HTTP webservice

We are working on an HTTP webservice load-balanced using haproxy. The webservice is accessed via SSL. It is a RESTful HTTP service and simply accepts JSON, does some work, and returns JSON. There is no notion of a session.
We have redundant load-balancers set up in front of a pair of redundant webservice servers. Each server sits behind Apache, where Apache is used as a proxy in order to handle SSL and logging. If it matters, our webservice is a Clojure (java) application using compojure (jetty) to handle HTTP.
This is a brief diagram showing the path of a client request through our existing system.
client request -> haproxy (load balancing) -> apache (ssl, logging) -> webservice
We would like any connection to the load-balancer to establish a persistent connection and then be served by the same server for all subsequent requests sent through that persistent connection. In other words, we don't want a persistent connection to haproxy making requests to more than one webservice server.
How would you recommend that we get this working? How can we "pin" a given connection to the load-balancer to a specific webservice server? How could we prevent accidentally loading down a specific webservice server with multiple intensive requests?
Using balance source in the defaults block, along with removing option httpclose entries did the trick.
In our HAProxy configuration we do this at the backend level, using the cookie option. This is because he have a number of sites, some of which we do want persistance for - others we do not.
In those that we do the backend looks like this in haproxy.cfg:
backend examplesite
cookie STK insert indirect nocache maxidle 30m maxlife 8h
server server1 192.168.0.1:80 cookie n1
server server2 192.168.0.2:80 cookie n2
This will set a cookie with the name STK on the first request. Haproxy will automatically assign a value to this cookie that it will then use to send subsequent requests to the same node.
We decided to also add the n1 and n2 cookie prefixes... this means that the cookie value will be prefixed with either n1 if the requests are going to node 1 or n2 if they are going to node 2. This is very helpful when debugging.
Either way I'd suggest taking a look at the configuration documentation around cookie options.
You might also want to look at the appsession option. This allows HAProxy to use an existing cookie (such as ASPNetSessionId or PHPSESSIONID) for the same purpose.
I had problems with it before, but recently had an answer to a question of Server Fault which should resolve this. You could give it a go as it saves using an extra cookie in your requests. Can't get appsession setting in HAProxy to work.