Implement Load Balancing using Ribbon - load-balancing

I am new to spring cloud and microservices. I am planning to implement load balancing on an independent micro service and need understand how to implement load Balancing using zuul api gateway without using feign client and hard coding list of end points available in java or in application.properties file.Most of the sample codes available over internet are hard coding list of servers and using load balancer choose option to get available list of end points to perform load balancing.Please suggest a way to implement this.

You need service-registry like eureka-server form which zuul will gather information about registered services. If there will be multiple services with same name load balancing will work out of the box.
You can also look at my code example here

Related

Vertx and port based routing

I want to use my Vertx web app with a Network Load Balancer. However, NLB does not work with path-based routing. I was not able to find solutions online.
Is it possible to get the entire query in Vertx as a string and then call the appropriate handler for NLB?
There is a solution in GCP called URL maps that is similar to Path-Based Routing in Amazon. If you want to move specific traffic to a specific server, using url-map you can select what backed service you want to reach for a specific traffic.

How to expose service layer with public and internal endpoints in Azure

I have a web app that talks to a service layer via WCF. These need to be internal endpoints and should be .net TCP bindings. However I also have some services in the service layer that don't need to be consumed internally but need to be exposed to the outside world i.e. http/https input endpoints. What is the best way in implementing this in Azure?
I was hoping someone could provide clarification / advice on the following points:
If I use internal endpoints are these load balanced? There seems to be a lot of contradicting info around the web. I have read that you need to implement your own algorithm, but I have also read that this has now been implemented by Microsoft and it is automatic.
Should the service layer be a web role or a worker role? It seems that there is a bit of a workaround to get internal TCP bindings working with a web role?
Is there a specific set of guidelines as to which one to use? i.e. web role or worker role.
I am assuming I am going to need two instances regardless of whether or not I use a web role or worker role? but wouldn't this depend on the first point? i.e. if there is no load balancer is there even any point in having 2 worker role instances?
Would it be better to split my service layer into two layers? One to expose the internal endpoints and another to expose the public endpoints?
Thanks in advance.
My previous answer got truncated. Take a look at Azure Service bus, you can create relays there to expose your internal WCF services
You can use a service relay for this, take a look # Azure

How do I implement basic API gateway

I am working on one school project, And my task is to make a simple api gateway, which can placed between any of the 3rd party api and the end users, tha gateway can be used for defining usage limits of the api or to do some security analysis, I am totally new to this, I know the basic concept of API gateway, but don't know how do I implement it using JAVA.
Can anyone please give me some starting point where to start implementation of API gateway?
And what are the frameworks I should use and for what purpose?
Thanks,
Nixit Patel
In a nutshell, API gateway exposes public APIs, applies policies (authentication - typically via OAuth, throttling, adherence to the the defined API, caching, etc.) and then (if allowed) optionally applies transformation rules and forwards the call to the backend. Then, when the backend responds, gateway (after optionally applying transformation rules again) forwards the response to the original caller. Plus, there would typically be an API management solution around it providing subscriber portal, user management, analytics, etc.
So basically any web service framework would work as a quick DYI solution.
You can also use plugin model of an open-source load-balancer such as NGINX.
Or take an open-source API Gateway to learn from it - e.g. WSO2 API Manager (the easiest way to see it in action is the hosted version: WSO2 API Cloud)

Multiple service with Single endpoint in Client side (Consuming Application)

I am having multiple WCF service but while consuming the service in Web application each service having its own end point to access the service. I need to have single end point in my web application to access all the services. Is there any other way except partial class.
No this can't be done. You can't merge multiple services into one endpoint.
You mention a partial class definition. That actually means you merge your different services together and expose them as one single service. This can off course be done and would give you one single access point (since it's just one service).
This way you could still logically separate the code in different files and let the them each implement a single interface. The service as a whole would implement a combined interface of all the different elements and that's what you would expose as a service endpoint.
--EDIT--
I personally wouldn't merge the services into one big service because that one big service will have to process all the incoming request. What if you want a certain configuration setting for one service, or you want to do some load balancing and move several services to another server?
If the problem is in maintaning the web.config files, you should have a look at web.config transformations. That way you can automate the process of configuring your application for different deployment scenarios.

What are the best practices for caching 3rd party API calls?

Our team currently operates 4-5 applications, and all of those applications use various 3rd party services (SimpleGeo, FB graph API, Yelp API, StrikeIron, etc). There is large overlap between applications, and frequently we call the same APIs for the same input parameters multiple times. Obviously that is not ideal: it is slow and it is expensive (some of the APIs are not free).
What are the best practices for caching these API calls across multiple applications? I see several options:
Write a custom app that creates facade for all of those APIs, and change all of my apps to use it.
Configure some sort of HTTP proxy in a very aggressive caching mode, and perform connections to APIs via that proxy.
Are there any other options I am missing?
Is there anything wrong with option 2? What HTTP proxy would you recommend for it (Squid, Varnish, Nginx, etc)?
You can use any of the three, but I would go with squid. Squid was created (and is heavily used) for this purpose (as a caching proxy). Varnish is designed as a Reverse Proxy (a cache in front of your own back-end), and nginx more like a load balancer and web processor (serving files and dynamic pages).