We are trying to improve the application performance we are using the struts2,jsp and webservices and retriving the data from service and display response in jsp page using ajax.
This is taking approximately 15 secs my client is asking reduce this time. So we are implementing the Parallelize downloads across hostnames
How can we load the images and js files from different sub host names?
Please suggest
How can we load the images and js
files from different sub host names?
You use subdomains pointing to different servers.
You can, for example, configure your DNS so that, images.example.org points to Amazon S3 while js.example.org points to a dedicated server in Timbuktu while all the other resources are downloaded from your "main" server(s) (whatever that is).
Related
Using Tomcat or JBoss, how do I transfer and save dynamic image content from an image repository on one server to a number of other servers (machines) on the same network without writing a Client/Server application?
The web site I am building contains a large number of images that will only be saved and shared on one machine. All of the web app servers need to be able to access these files.
Kermit Love, here are a few suggestions based on your requirements. Note that none of these are based on Java nor specific to Tomcat / JBoss.
Option 1 : Using a NAS or a Shared Directory
Using a specific hardware (NAS), a file server (Samba) or a simple shared directory over the network would allow all you machines to access the content through the network.
Pros:
This solution can scale
Setup is easy
Cons:
The network overhead may slow down your global solution depending on your needs (access frequency, images sizes, ...)
No high-availability (fault tolerance)
Option 2 : Using an upfront server dedicated to load balancing / reverse-proxy / serving files
You can use a simple Nginx / Apache server to deliver "static" content while routing trafic to your application servers.
Pros:
Efficient way to serve images to clients.
You separate the concerns (business logic vs serving files).
Cons: No high-availability (fault tolerance)
Option 3 : Using rsync to synchronise file systems
You can define a cron based rule to run a rsync command every N seconds/minutes to ensure all your machines have the data available.
Pros:
Easy to setup
Free (no need extra hardware, for now)
(slightly) better performance in the long term than option 1 (no repeated network overhead).
Cons:
Yet an extra-process
Doesn't scale horizontally
Files won't be immediately accessible
I have a java application running on Apache tomcat on two different servers A and B. The application involves uploading and downloading files mostly pdf and images. Currently I have an FTP server F ,where I host all my files. Now I am having the following problems:
Uploading and Downloading of files is causing issues while creating FTP connection (Sometimes it connects and Sometimes it throws the timeout error).
I am displaying images by converting them into BASE 64 format, which causes the same trouble discussed above.
Solutions that I can think of is
Use application server to host files (Is it a right practice??),
also as I have two different servers running the application it
would be tough to create a sync between them.
I have heard something about shared file hosting but that will cause security troubles.
Any solutions for my above problem would be really appreciated.Thanks
If your application uses a database, you could store these files as LOBs (Character or binary large objects)in the database instead of on disk.
If the files are small you can store them as CLOB or BLOB in a database and serve them through HTTP (rest endpoints from your application server)
If your files are large, store them in a NAS or any other shared storage. Don't convert them to BASE64 instead serve them as binary attachments over HTTP (rest endpoints from your application server). You may or may not store the file locations somewhere maybe in Database to keep track of it.
We have one web application(With Spring, hibernate and MySQL as a Database) in which multiple users can store the heavy videos(pre-recorded or record from application itself) on server at same time.
In that scenario, server load would be definitely more there. We are assuming there would be 500-2000 users in the application.
So what strategy i should use to reduce the load from server and make the response time faster.
1) Storing the videos on our server(With large Disk Space), and using the ActiveMQ/RabbitMQ mechanisms for File Upload and download in the Queues.
2) Storing the videos on some third party server(like YouTube,vimeo etc) that will upload all the videos on one central account. I had recently check this thing with you tube and vimeo but they require the end user login credentials for each upload. And i don;t want in my application that end-users to provide their credentials before each upload.
Is there any other way to reduce the work load and make the response time better for simultaneously upload on server, then please guide.
Thanks In Advance,
Arun
Multi servers can help.
On a single server:
If you use a single core processor - only ONE client will get served.
If you use a multi core processor and you are oppening a new thread for a new connection - only #ofCores clients will get served, and even that is not correct because your local memory might run out before your os will save the data to your local hard disk (which has one bus), so serving 500-2000 clients leads you to a multi server solution.
As a kind of personal project, I'm trying to develop a Java Applet that will stream from a collection of music that I will host on the same machine as the applet. I know when you request files in an applet, it looks for them in the files of the computer which is accessing the applet. I, however, want to access files that are hosted on the same server as the applet.
My intention is to, when the client wants to stream a specific song, the server will begin loading the data and streaming the data to the client. I think this would be possible using the URL class in Java, but would that not be going out to the internet only to come back to the very same server to get its files? Or will it recognize that the files are local and access them without going out to the web?
Summary: What is the best way for an applet to access files that are hosted on the same server as itself?
An applet runs on the client machine. In order to access files the server you're going to have implement functionality on the server-side to expose those files to your client. There are various ways to do this in Java - the most common would be:
1) a custom servlet or
2) a web service
Here are some links to articles which could be helpful:
Can a web service return a stream?
FileServlet serving from absolute path
As an aside I think your question is quite broad. You're probably going to have to investigate one or both of the methods above, try to implement one of them and then come back to SO with more specific questions.
What would be a scalable file upload/download system/database?
I'm building a website where users can login, upload images that are private, but truly private. I can't upload them to a map on the harddisk of a server, since that would not scale (what happend if we add more servers?) and it wouldn't be private since everyone could go:
http://127.372.171.33/images/private_picture.png
and download the file.
I am building the project in Play Framework (scala/java)
How do websites like flickr handle these kind of things? Do they put them in a database? And what kind of database would be suitable for this situation?
Thanks for help
I can't tell you how those big sites handle it but putting those images into a database might be one way.
Another way would be to put the files into a virtual filesystem that spans a cluster of servers or distribute them onto different servers and just don't make the directories that contain the images visible to the webserver. Thus nobody should be able to open the image just using the server and the path on that server.
To actually deliver the images you could them implement some streaming service that sends a bytestream to the browser for display (like the webservers would do as well). This service could first check the download permissions for the requested image.